uv-python-workflow

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

uv Python Workflow

uv Python 工作流

All Python dependency and environment management in this codebase uses
uv
exclusively.
本代码库中所有Python依赖与环境管理均仅使用
uv

Package management

包管理

  • Add dependencies:
    uv add <package>
  • Remove dependencies:
    uv remove <package>
  • Install/sync the current project:
    uv sync
  • Run a command inside the project environment:
    uv run <command>
  • Never use
    pip install
    ,
    pip-compile
    , or bare
    python -m venv
    .
  • 添加依赖:
    uv add <package>
  • 移除依赖:
    uv remove <package>
  • 安装/同步当前项目:
    uv sync
  • 在项目环境中运行命令:
    uv run <command>
  • 切勿使用
    pip install
    pip-compile
    或直接使用
    python -m venv

Workspace layout

工作区布局

Projects may be organized as a
uv
workspace. Code locations managed by
dg
do not use
uv
workspaces — they rely on the
dg
workspace instead.
项目可组织为
uv
工作区。由
dg
管理的代码位置不使用
uv
工作区——它们依赖于
dg
工作区。

Docker / container images

Docker / 容器镜像

When building a Python app inside a Docker image, create a relocatable virtual environment so it works after the image layers are assembled:
dockerfile
RUN uv venv --relocatable /app/.venv
RUN uv sync --frozen --no-dev
Do not mount
ol-orchestrate-lib
(or any shared library) as a volume at runtime. Shared libraries are installed as build-time dependencies only.
在Docker镜像中构建Python应用时,创建一个可重定位的虚拟环境,以便在镜像层组装后仍能正常工作:
dockerfile
RUN uv venv --relocatable /app/.venv
RUN uv sync --frozen --no-dev
运行时不要
ol-orchestrate-lib
(或任何共享库)作为卷挂载。共享库仅作为构建时依赖安装。

Running pre-commit and type checks

运行预提交与类型检查

bash
uv run pre-commit run --all-files
uv run mypy <package>
bash
uv run pre-commit run --all-files
uv run mypy <package>