Guest User

uv-long-version

a guest
Feb 19th, 2025
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.68 KB | None | 0 0
  1. # uv
  2.  
  3. [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
  4. [![image](https://img.shields.io/pypi/v/uv.svg)](https://pypi.python.org/pypi/uv)
  5. [![image](https://img.shields.io/pypi/l/uv.svg)](https://pypi.python.org/pypi/uv)
  6. [![image](https://img.shields.io/pypi/pyversions/uv.svg)](https://pypi.python.org/pypi/uv)
  7. [![Actions status](https://github.com/astral-sh/uv/actions/workflows/ci.yml/badge.svg)](https://github.com/astral-sh/uv/actions)
  8. [![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord&logoColor=white)](https://discord.gg/astral-sh)
  9.  
  10. An extremely fast Python package and project manager, written in Rust.
  11.  
  12. ## Highlights
  13.  
  14. - 🚀 A single tool to replace `pip`, `pip-tools`, `pipx`, `poetry`, `pyenv`, `twine`, `virtualenv`,
  15. and more.
  16. - ⚡️ [10-100x faster](https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md) than `pip`.
  17. - 🐍 [Installs and manages](#python-management) Python versions.
  18. - 🛠️ [Runs and installs](#tool-management) Python applications.
  19. - ❇️ [Runs single-file scripts](#script-support), with support for
  20. [inline dependency metadata](https://docs.astral.sh/uv/guides/scripts#declaring-script-dependencies).
  21. - 🗂️ Provides [comprehensive project management](#project-management), with a
  22. [universal lockfile](https://docs.astral.sh/uv/concepts/projects#project-lockfile).
  23. - 🔩 Includes a [pip-compatible interface](#a-pip-compatible-interface) for a performance boost with
  24. a familiar CLI.
  25. - 🏢 Supports Cargo-style [workspaces](https://docs.astral.sh/uv/concepts/workspaces) for scalable
  26. projects.
  27. - 💾 Disk-space efficient, with a [global cache](https://docs.astral.sh/uv/concepts/cache) for
  28. dependency deduplication.
  29. - ⏬ Installable without Rust or Python via `curl` or `pip`.
  30. - 🖥️ Supports macOS, Linux, and Windows.
  31.  
  32. uv is backed by [Astral](https://astral.sh), the creators of
  33. [Ruff](https://github.com/astral-sh/ruff).
  34.  
  35. ## Installation
  36.  
  37. Install uv with our standalone installers:
  38.  
  39. ```bash
  40. # On macOS and Linux.
  41. curl -LsSf https://astral.sh/uv/install.sh | sh
  42. ```
  43.  
  44. ```bash
  45. # On Windows.
  46. powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  47. ```
  48.  
  49. Or, from [PyPI](https://pypi.org/project/uv/):
  50.  
  51. ```bash
  52. # With pip.
  53. pip install uv
  54. ```
  55.  
  56. ```bash
  57. # Or pipx.
  58. pipx install uv
  59. ```
  60.  
  61. If installed via the standalone installer, uv can update itself to the latest version:
  62.  
  63. ```bash
  64. uv self update
  65. ```
  66.  
  67. See the [installation documentation](https://docs.astral.sh/uv/getting-started/installation/) for
  68. details and alternative installation methods.
  69.  
  70. ## Documentation
  71.  
  72. uv's documentation is available at [docs.astral.sh/uv](https://docs.astral.sh/uv).
  73.  
  74. Additionally, the command line reference documentation can be viewed with `uv help`.
  75.  
  76. ## Features
  77.  
  78. ### Project management
  79.  
  80. uv manages project dependencies and environments, with support for lockfiles, workspaces, and more,
  81. similar to `rye` or `poetry`:
  82.  
  83. ```console
  84. $ uv init example
  85. Initialized project `example` at `/home/user/example`
  86.  
  87. $ cd example
  88.  
  89. $ uv add ruff
  90. Creating virtual environment at: .venv
  91. Resolved 2 packages in 170ms
  92. Built example @ file:///home/user/example
  93. Prepared 2 packages in 627ms
  94. Installed 2 packages in 1ms
  95. + example==0.1.0 (from file:///home/user/example)
  96. + ruff==0.5.6
  97.  
  98. $ uv run ruff check
  99. All checks passed!
  100. ```
  101.  
  102. See the [project documentation](https://docs.astral.sh/uv/guides/projects/) to get started.
  103.  
  104. uv also supports building and publishing projects, even if they're not managed with uv. See the
  105. [publish guide](https://docs.astral.sh/uv/guides/publish/) to learn more.
  106.  
  107. ### Tool management
  108.  
  109. uv executes and installs command-line tools provided by Python packages, similar to `pipx`.
  110.  
  111. Run a tool in an ephemeral environment using `uvx` (an alias for `uv tool run`):
  112.  
  113. ```console
  114. $ uvx pycowsay 'hello world!'
  115. Resolved 1 package in 167ms
  116. Installed 1 package in 9ms
  117. + pycowsay==0.0.0.2
  118. """
  119.  
  120. ------------
  121. < hello world! >
  122. ------------
  123. \ ^__^
  124. \ (oo)\_______
  125. (__)\ )\/\
  126. ||----w |
  127. || ||
  128. ```
  129.  
  130. Install a tool with `uv tool install`:
  131.  
  132. ```console
  133. $ uv tool install ruff
  134. Resolved 1 package in 6ms
  135. Installed 1 package in 2ms
  136. + ruff==0.5.6
  137. Installed 1 executable: ruff
  138.  
  139. $ ruff --version
  140. ruff 0.5.6
  141. ```
  142.  
  143. See the [tools documentation](https://docs.astral.sh/uv/guides/tools/) to get started.
  144.  
  145. ### Python management
  146.  
  147. uv installs Python and allows quickly switching between versions.
  148.  
  149. Install multiple Python versions:
  150.  
  151. ```console
  152. $ uv python install 3.10 3.11 3.12
  153. Searching for Python versions matching: Python 3.10
  154. Searching for Python versions matching: Python 3.11
  155. Searching for Python versions matching: Python 3.12
  156. Installed 3 versions in 3.42s
  157. + cpython-3.10.14-macos-aarch64-none
  158. + cpython-3.11.9-macos-aarch64-none
  159. + cpython-3.12.4-macos-aarch64-none
  160. ```
  161.  
  162. Download Python versions as needed:
  163.  
  164. ```console
  165. $ uv venv --python 3.12.0
  166. Using Python 3.12.0
  167. Creating virtual environment at: .venv
  168. Activate with: source .venv/bin/activate
  169.  
  170. $ uv run --python [email protected] -- python --version
  171. Python 3.8.16 (a9dbdca6fc3286b0addd2240f11d97d8e8de187a, Dec 29 2022, 11:45:30)
  172. [PyPy 7.3.11 with GCC Apple LLVM 13.1.6 (clang-1316.0.21.2.5)] on darwin
  173. Type "help", "copyright", "credits" or "license" for more information.
  174. >>>>
  175. ```
  176.  
  177. Use a specific Python version in the current directory:
  178.  
  179. ```console
  180. $ uv python pin [email protected]
  181. Pinned `.python-version` to `[email protected]`
  182. ```
  183.  
  184. See the [Python installation documentation](https://docs.astral.sh/uv/guides/install-python/) to get
  185. started.
  186.  
  187. ### Script support
  188.  
  189. uv manages dependencies and environments for single-file scripts.
  190.  
  191. Create a new script and add inline metadata declaring its dependencies:
  192.  
  193. ```console
  194. $ echo 'import requests; print(requests.get("https://astral.sh"))' > example.py
  195.  
  196. $ uv add --script example.py requests
  197. Updated `example.py`
  198. ```
  199.  
  200. Then, run the script in an isolated virtual environment:
  201.  
  202. ```console
  203. $ uv run example.py
  204. Reading inline script metadata from: example.py
  205. Installed 5 packages in 12ms
  206. <Response [200]>
  207. ```
  208.  
  209. See the [scripts documentation](https://docs.astral.sh/uv/guides/scripts/) to get started.
  210.  
  211. ### A pip-compatible interface
  212.  
  213. uv provides a drop-in replacement for common `pip`, `pip-tools`, and `virtualenv` commands.
  214.  
  215. uv extends their interfaces with advanced features, such as dependency version overrides,
  216. platform-independent resolutions, reproducible resolutions, alternative resolution strategies, and
  217. more.
  218.  
  219. Migrate to uv without changing your existing workflows — and experience a 10-100x speedup — with the
  220. `uv pip` interface.
  221.  
  222. Compile requirements into a platform-independent requirements file:
  223.  
  224. ```console
  225. $ uv pip compile docs/requirements.in \
  226. --universal \
  227. --output-file docs/requirements.txt
  228. Resolved 43 packages in 12ms
  229. ```
  230.  
  231. Create a virtual environment:
  232.  
  233. ```console
  234. $ uv venv
  235. Using Python 3.12.3
  236. Creating virtual environment at: .venv
  237. Activate with: source .venv/bin/activate
  238. ```
  239.  
  240. Install the locked requirements:
  241.  
  242. ```console
  243. $ uv pip sync docs/requirements.txt
  244. Resolved 43 packages in 11ms
  245. Installed 43 packages in 208ms
  246. + babel==2.15.0
  247. + black==24.4.2
  248. + certifi==2024.7.4
  249. ...
  250. ```
  251.  
  252. # Features
  253.  
  254. uv provides essential features for Python development — from installing Python and hacking on simple
  255. scripts to working on large projects that support multiple Python versions and platforms.
  256.  
  257. uv's interface can be broken down into sections, which can be used independently or together.
  258.  
  259. ## Python versions
  260.  
  261. Installing and managing Python itself.
  262.  
  263. - `uv python install`: Install Python versions.
  264. - `uv python list`: View available Python versions.
  265. - `uv python find`: Find an installed Python version.
  266. - `uv python pin`: Pin the current project to use a specific Python version.
  267. - `uv python uninstall`: Uninstall a Python version.
  268.  
  269. See the [guide on installing Python](../guides/install-python.md) to get started.
  270.  
  271. ## Scripts
  272.  
  273. Executing standalone Python scripts, e.g., `example.py`.
  274.  
  275. - `uv run`: Run a script.
  276. - `uv add --script`: Add a dependency to a script
  277. - `uv remove --script`: Remove a dependency from a script
  278.  
  279. See the [guide on running scripts](../guides/scripts.md) to get started.
  280.  
  281. ## Projects
  282.  
  283. Creating and working on Python projects, i.e., with a `pyproject.toml`.
  284.  
  285. - `uv init`: Create a new Python project.
  286. - `uv add`: Add a dependency to the project.
  287. - `uv remove`: Remove a dependency from the project.
  288. - `uv sync`: Sync the project's dependencies with the environment.
  289. - `uv lock`: Create a lockfile for the project's dependencies.
  290. - `uv run`: Run a command in the project environment.
  291. - `uv tree`: View the dependency tree for the project.
  292. - `uv build`: Build the project into distribution archives.
  293. - `uv publish`: Publish the project to a package index.
  294.  
  295. See the [guide on projects](../guides/projects.md) to get started.
  296.  
  297. ## Tools
  298.  
  299. Running and installing tools published to Python package indexes, e.g., `ruff` or `black`.
  300.  
  301. - `uvx` / `uv tool run`: Run a tool in a temporary environment.
  302. - `uv tool install`: Install a tool user-wide.
  303. - `uv tool uninstall`: Uninstall a tool.
  304. - `uv tool list`: List installed tools.
  305. - `uv tool update-shell`: Update the shell to include tool executables.
  306.  
  307. See the [guide on tools](../guides/tools.md) to get started.
  308.  
  309. ## The pip interface
  310.  
  311. Manually managing environments and packages — intended to be used in legacy workflows or cases where
  312. the high-level commands do not provide enough control.
  313.  
  314. Creating virtual environments (replacing `venv` and `virtualenv`):
  315.  
  316. - `uv venv`: Create a new virtual environment.
  317.  
  318. See the documentation on [using environments](../pip/environments.md) for details.
  319.  
  320. Managing packages in an environment (replacing [`pip`](https://github.com/pypa/pip) and
  321. [`pipdeptree`](https://github.com/tox-dev/pipdeptree)):
  322.  
  323. - `uv pip install`: Install packages into the current environment.
  324. - `uv pip show`: Show details about an installed package.
  325. - `uv pip freeze`: List installed packages and their versions.
  326. - `uv pip check`: Check that the current environment has compatible packages.
  327. - `uv pip list`: List installed packages.
  328. - `uv pip uninstall`: Uninstall packages.
  329. - `uv pip tree`: View the dependency tree for the environment.
  330.  
  331. See the documentation on [managing packages](../pip/packages.md) for details.
  332.  
  333. Locking packages in an environment (replacing [`pip-tools`](https://github.com/jazzband/pip-tools)):
  334.  
  335. - `uv pip compile`: Compile requirements into a lockfile.
  336. - `uv pip sync`: Sync an environment with a lockfile.
  337.  
  338. See the documentation on [locking environments](../pip/compile.md) for details.
  339.  
  340. !!! important
  341.  
  342. 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.
  343.  
  344. ## Utility
  345.  
  346. Managing and inspecting uv's state, such as the cache, storage directories, or performing a
  347. self-update:
  348.  
  349. - `uv cache clean`: Remove cache entries.
  350. - `uv cache prune`: Remove outdated cache entries.
  351. - `uv cache dir`: Show the uv cache directory path.
  352. - `uv tool dir`: Show the uv tool directory path.
  353. - `uv python dir`: Show the uv installed Python versions path.
  354. - `uv self update`: Update uv to the latest version.
  355.  
  356. ## Next steps
  357.  
  358. Read the [guides](../guides/index.md) for an introduction to each feature, check out
  359. [concept](../concepts/index.md) pages for in-depth details about uv's features, or learn how to
  360. [get help](./help.md) if you run into any problems.
Add Comment
Please, Sign In to add comment