uv-python-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseuv Python Workflow
uv Python 工作流
All Python dependency and environment management in this codebase uses exclusively.
uv本代码库中所有Python依赖与环境管理均仅使用。
uvPackage 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, or barepip-compile.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 workspace. Code locations managed by
do not use workspaces — they rely on the workspace instead.
uvdguvdg项目可组织为工作区。由管理的代码位置不使用工作区——它们依赖于工作区。
uvdguvdgDocker / 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-devDo not mount (or any shared library) as a volume at
runtime. Shared libraries are installed as build-time dependencies only.
ol-orchestrate-lib在Docker镜像中构建Python应用时,创建一个可重定位的虚拟环境,以便在镜像层组装后仍能正常工作:
dockerfile
RUN uv venv --relocatable /app/.venv
RUN uv sync --frozen --no-dev运行时不要将(或任何共享库)作为卷挂载。共享库仅作为构建时依赖安装。
ol-orchestrate-libRunning 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>