@tank/uv-python
1.0.0Description
Python project management with uv, the Rust-powered replacement for pip, poetry, pyenv, and virtualenv. Covers project init, dependency management, lockfiles, Python version management, scripts with inline metadata, tool management, workspaces, building/publishing, Docker integration, CI/CD patterns, and migration from pip/poetry/pipenv..
Download
Verified
tank install @tank/uv-pythonUV Python
Core Philosophy
- One tool replaces many -- uv unifies pip, pip-tools, pipx, poetry, pyenv, virtualenv, and twine into a single binary. Prefer uv's project interface over its pip-compatibility layer for new projects.
- Speed is a feature -- 10-100x faster than pip through Rust implementation, aggressive caching, and parallel resolution. Use the global cache and lockfile to maximize this advantage.
- Lockfiles are non-negotiable -- Always commit
uv.lockto version control. The universal lockfile captures cross-platform resolutions, eliminating "works on my machine" failures. - Declarative over imperative -- Define dependencies in
pyproject.toml, not through ad-hocpip install. Use inline metadata for scripts,pyproject.tomlfor projects. - Environments are disposable -- uv creates and manages
.venvautomatically. Never manually modify the project environment withuv pip install-- useuv addfor project deps,uv run --withfor one-off needs.
Quick-Start: Common Problems
"Start a new Python project"
- Run
uv init my-project(application) oruv init --lib my-lib(library) - Add dependencies:
uv add fastapi httpx - Add dev dependencies:
uv add --dev pytest ruff - Run code:
uv run python main.pyoruv run pytest-> Seereferences/project-management.md
"Migrate from pip/poetry to uv"
- Import requirements:
uv add -r requirements.in -c requirements.txt - Import dev deps:
uv add --dev -r requirements-dev.in -c requirements-dev.txt - From poetry: copy deps from
[tool.poetry.dependencies]to[project.dependencies] - Verify:
uv sync --lockedthenuv run pytest-> Seereferences/migration.md
"Run a one-off script with dependencies"
- Create script:
uv init --script example.py --python 3.12 - Add inline deps:
uv add --script example.py requests rich - Run:
uv run example.py-> Seereferences/scripts-and-tools.md
"Set up CI/CD with uv"
- Install:
uses: astral-sh/setup-uv@v7with pinned version - Sync:
uv sync --locked --all-extras --dev - Test:
uv run pytest - Cache: enable with
enable-cache: true-> Seereferences/ci-cd-integration.md
"Optimize Docker builds with uv"
- Copy binary:
COPY --from=ghcr.io/astral-sh/uv:0.11.3 /uv /uvx /bin/ - Use intermediate layers: sync deps first, copy source second
- Cache mount:
--mount=type=cache,target=/root/.cache/uv-> Seereferences/docker-integration.md
Decision Trees
Project Type Selection
| Signal | Command |
|---|---|
| Application (CLI, web service) | uv init my-app |
| Library (published to PyPI) | uv init --lib my-lib |
| Script (single file) | uv init --script example.py |
| Monorepo with shared deps | uv init + [tool.uv.workspace] |
Dependency Management
| Need | Approach |
|---|---|
| Production dependency | uv add package |
| Dev-only dependency | uv add --dev package |
| Custom dependency group | uv add --group lint ruff |
| Optional extra | uv add --optional viz matplotlib |
| Git source | uv add git+https://github.com/org/repo |
| Local path | uv add --editable ../my-lib |
| Platform-specific | uv add "pkg; sys_platform == 'linux'" |
Python Version Management
| Task | Command |
|---|---|
| Install Python | uv python install 3.12 |
| Pin version for project | uv python pin 3.12 |
| Use specific version | uv run --python 3.11 script.py |
| List installed | uv python list |
Reference Index
| File | Contents |
|---|---|
references/project-management.md | Project init, pyproject.toml structure, dependency management (add/remove/sync/lock), dependency sources, optional and dev deps, dependency groups |
references/python-and-environments.md | Python version installation and pinning, virtual environment creation and management, environment variables, .python-version files |
references/scripts-and-tools.md | Inline script metadata (PEP 723), uv run, uv tool install, uvx, shebangs, script locking |
references/lockfile-and-resolution.md | uv.lock format, universal resolution, upgrade strategies, conflict resolution, resolution overrides, PEP 751 pylock.toml |
references/workspaces.md | Workspace setup, member management, shared lockfile, workspace sources, layout patterns, when to use vs path deps |
references/building-and-publishing.md | uv build, uv publish, build systems, version bumping, trusted publishing, PyPI and custom indexes |
references/docker-integration.md | Docker images, multi-stage builds, intermediate layers, cache optimization, workspace Docker patterns, compose watch |
references/ci-cd-integration.md | GitHub Actions (setup-uv), caching, matrix testing, trusted publishing workflow, GitLab CI, private repos |
references/migration.md | Migration from pip/pip-tools, poetry, pipenv, pdm; requirements file import, constraint preservation, platform-specific migration |