Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # uv
- [](https://github.com/astral-sh/uv)
- [](https://pypi.python.org/pypi/uv)
- [](https://pypi.python.org/pypi/uv)
- [](https://pypi.python.org/pypi/uv)
- [](https://github.com/astral-sh/uv/actions)
- [](https://discord.gg/astral-sh)
- An extremely fast Python package and project manager, written in Rust.
- ## Highlights
- - 🚀 A single tool to replace `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `twine`, `virtualenv`,
- and more.
- - ⚡️ [10-100x faster](https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md) than `pip`.
- - 🐍 [Installs and manages](#python-management) Python versions.
- - 🛠️ [Runs and installs](#tool-management) Python applications.
- - ❇️ [Runs single-file scripts](#script-support), with support for
- [inline dependency metadata](https://docs.astral.sh/uv/guides/scripts#declaring-script-dependencies).
- - 🗂️ Provides [comprehensive project management](#project-management), with a
- [universal lockfile](https://docs.astral.sh/uv/concepts/projects#project-lockfile).
- - 🔩 Includes a [pip-compatible interface](#a-pip-compatible-interface) for a performance boost with
- a familiar CLI.
- - 🏢 Supports Cargo-style [workspaces](https://docs.astral.sh/uv/concepts/workspaces) for scalable
- projects.
- - 💾 Disk-space efficient, with a [global cache](https://docs.astral.sh/uv/concepts/cache) for
- dependency deduplication.
- - ⏬ Installable without Rust or Python via `curl` or `pip`.
- - 🖥️ Supports macOS, Linux, and Windows.
- uv is backed by [Astral](https://astral.sh), the creators of
- [Ruff](https://github.com/astral-sh/ruff).
- ## Installation
- Install uv with our standalone installers:
- ```bash
- # On macOS and Linux.
- curl -LsSf https://astral.sh/uv/install.sh | sh
- ```
- ```bash
- # On Windows.
- powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
- ```
- Or, from [PyPI](https://pypi.org/project/uv/):
- ```bash
- # With pip.
- pip install uv
- ```
- ```bash
- # Or pipx.
- pipx install uv
- ```
- If installed via the standalone installer, uv can update itself to the latest version:
- ```bash
- uv self update
- ```
- See the [installation documentation](https://docs.astral.sh/uv/getting-started/installation/) for
- details and alternative installation methods.
- ## Documentation
- uv's documentation is available at [docs.astral.sh/uv](https://docs.astral.sh/uv).
- Additionally, the command line reference documentation can be viewed with `uv help`.
- ## Features
- ### Project management
- uv manages project dependencies and environments, with support for lockfiles, workspaces, and more,
- similar to `rye` or `poetry`:
- ```console
- $ uv init example
- Initialized project `example` at `/home/user/example`
- $ cd example
- $ uv add ruff
- Creating virtual environment at: .venv
- Resolved 2 packages in 170ms
- Built example @ file:///home/user/example
- Prepared 2 packages in 627ms
- Installed 2 packages in 1ms
- + example==0.1.0 (from file:///home/user/example)
- + ruff==0.5.6
- $ uv run ruff check
- All checks passed!
- ```
- See the [project documentation](https://docs.astral.sh/uv/guides/projects/) to get started.
- uv also supports building and publishing projects, even if they're not managed with uv. See the
- [publish guide](https://docs.astral.sh/uv/guides/publish/) to learn more.
- ### Tool management
- uv executes and installs command-line tools provided by Python packages, similar to `pipx`.
- Run a tool in an ephemeral environment using `uvx` (an alias for `uv tool run`):
- ```console
- $ uvx pycowsay 'hello world!'
- Resolved 1 package in 167ms
- Installed 1 package in 9ms
- + pycowsay==0.0.0.2
- """
- ------------
- < hello world! >
- ------------
- \ ^__^
- \ (oo)\_______
- (__)\ )\/\
- ||----w |
- || ||
- ```
- Install a tool with `uv tool install`:
- ```console
- $ uv tool install ruff
- Resolved 1 package in 6ms
- Installed 1 package in 2ms
- + ruff==0.5.6
- Installed 1 executable: ruff
- $ ruff --version
- ruff 0.5.6
- ```
- See the [tools documentation](https://docs.astral.sh/uv/guides/tools/) to get started.
- ### Python management
- uv installs Python and allows quickly switching between versions.
- Install multiple Python versions:
- ```console
- $ uv python install 3.10 3.11 3.12
- Searching for Python versions matching: Python 3.10
- Searching for Python versions matching: Python 3.11
- Searching for Python versions matching: Python 3.12
- Installed 3 versions in 3.42s
- + cpython-3.10.14-macos-aarch64-none
- + cpython-3.11.9-macos-aarch64-none
- + cpython-3.12.4-macos-aarch64-none
- ```
- Download Python versions as needed:
- ```console
- $ uv venv --python 3.12.0
- Using Python 3.12.0
- Creating virtual environment at: .venv
- Activate with: source .venv/bin/activate
- $ uv run --python [email protected] -- python --version
- Python 3.8.16 (a9dbdca6fc3286b0addd2240f11d97d8e8de187a, Dec 29 2022, 11:45:30)
- [PyPy 7.3.11 with GCC Apple LLVM 13.1.6 (clang-1316.0.21.2.5)] on darwin
- Type "help", "copyright", "credits" or "license" for more information.
- >>>>
- ```
- Use a specific Python version in the current directory:
- ```console
- $ uv python pin [email protected]
- Pinned `.python-version` to `[email protected]`
- ```
- See the [Python installation documentation](https://docs.astral.sh/uv/guides/install-python/) to get
- started.
- ### Script support
- uv manages dependencies and environments for single-file scripts.
- Create a new script and add inline metadata declaring its dependencies:
- ```console
- $ echo 'import requests; print(requests.get("https://astral.sh"))' > example.py
- $ uv add --script example.py requests
- Updated `example.py`
- ```
- Then, run the script in an isolated virtual environment:
- ```console
- $ uv run example.py
- Reading inline script metadata from: example.py
- Installed 5 packages in 12ms
- <Response [200]>
- ```
- See the [scripts documentation](https://docs.astral.sh/uv/guides/scripts/) to get started.
- ### A pip-compatible interface
- uv provides a drop-in replacement for common `pip`, `pip-tools`, and `virtualenv` commands.
- uv extends their interfaces with advanced features, such as dependency version overrides,
- platform-independent resolutions, reproducible resolutions, alternative resolution strategies, and
- more.
- Migrate to uv without changing your existing workflows — and experience a 10-100x speedup — with the
- `uv pip` interface.
- Compile requirements into a platform-independent requirements file:
- ```console
- $ uv pip compile docs/requirements.in \
- --universal \
- --output-file docs/requirements.txt
- Resolved 43 packages in 12ms
- ```
- Create a virtual environment:
- ```console
- $ uv venv
- Using Python 3.12.3
- Creating virtual environment at: .venv
- Activate with: source .venv/bin/activate
- ```
- Install the locked requirements:
- ```console
- $ uv pip sync docs/requirements.txt
- Resolved 43 packages in 11ms
- Installed 43 packages in 208ms
- + babel==2.15.0
- + black==24.4.2
- + certifi==2024.7.4
- ...
- ```
- # Features
- uv provides essential features for Python development — from installing Python and hacking on simple
- scripts to working on large projects that support multiple Python versions and platforms.
- uv's interface can be broken down into sections, which can be used independently or together.
- ## Python versions
- Installing and managing Python itself.
- - `uv python install`: Install Python versions.
- - `uv python list`: View available Python versions.
- - `uv python find`: Find an installed Python version.
- - `uv python pin`: Pin the current project to use a specific Python version.
- - `uv python uninstall`: Uninstall a Python version.
- See the [guide on installing Python](../guides/install-python.md) to get started.
- ## Scripts
- Executing standalone Python scripts, e.g., `example.py`.
- - `uv run`: Run a script.
- - `uv add --script`: Add a dependency to a script
- - `uv remove --script`: Remove a dependency from a script
- See the [guide on running scripts](../guides/scripts.md) to get started.
- ## Projects
- Creating and working on Python projects, i.e., with a `pyproject.toml`.
- - `uv init`: Create a new Python project.
- - `uv add`: Add a dependency to the project.
- - `uv remove`: Remove a dependency from the project.
- - `uv sync`: Sync the project's dependencies with the environment.
- - `uv lock`: Create a lockfile for the project's dependencies.
- - `uv run`: Run a command in the project environment.
- - `uv tree`: View the dependency tree for the project.
- - `uv build`: Build the project into distribution archives.
- - `uv publish`: Publish the project to a package index.
- See the [guide on projects](../guides/projects.md) to get started.
- ## Tools
- Running and installing tools published to Python package indexes, e.g., `ruff` or `black`.
- - `uvx` / `uv tool run`: Run a tool in a temporary environment.
- - `uv tool install`: Install a tool user-wide.
- - `uv tool uninstall`: Uninstall a tool.
- - `uv tool list`: List installed tools.
- - `uv tool update-shell`: Update the shell to include tool executables.
- See the [guide on tools](../guides/tools.md) to get started.
- ## The pip interface
- Manually managing environments and packages — intended to be used in legacy workflows or cases where
- the high-level commands do not provide enough control.
- Creating virtual environments (replacing `venv` and `virtualenv`):
- - `uv venv`: Create a new virtual environment.
- See the documentation on [using environments](../pip/environments.md) for details.
- Managing packages in an environment (replacing [`pip`](https://github.com/pypa/pip) and
- [`pipdeptree`](https://github.com/tox-dev/pipdeptree)):
- - `uv pip install`: Install packages into the current environment.
- - `uv pip show`: Show details about an installed package.
- - `uv pip freeze`: List installed packages and their versions.
- - `uv pip check`: Check that the current environment has compatible packages.
- - `uv pip list`: List installed packages.
- - `uv pip uninstall`: Uninstall packages.
- - `uv pip tree`: View the dependency tree for the environment.
- See the documentation on [managing packages](../pip/packages.md) for details.
- Locking packages in an environment (replacing [`pip-tools`](https://github.com/jazzband/pip-tools)):
- - `uv pip compile`: Compile requirements into a lockfile.
- - `uv pip sync`: Sync an environment with a lockfile.
- See the documentation on [locking environments](../pip/compile.md) for details.
- !!! important
- These commands do not exactly implement the interfaces and behavior of the tools they are based on. The further you stray from common workflows, the more likely you are to encounter differences. Consult the [pip-compatibility guide](../pip/compatibility.md) for details.
- ## Utility
- Managing and inspecting uv's state, such as the cache, storage directories, or performing a
- self-update:
- - `uv cache clean`: Remove cache entries.
- - `uv cache prune`: Remove outdated cache entries.
- - `uv cache dir`: Show the uv cache directory path.
- - `uv tool dir`: Show the uv tool directory path.
- - `uv python dir`: Show the uv installed Python versions path.
- - `uv self update`: Update uv to the latest version.
- ## Next steps
- Read the [guides](../guides/index.md) for an introduction to each feature, check out
- [concept](../concepts/index.md) pages for in-depth details about uv's features, or learn how to
- [get help](./help.md) if you run into any problems.
Add Comment
Please, Sign In to add comment