|
2 | 2 |
|
3 | 3 | ## Main packages to handle virtual environments
|
4 | 4 | - [venv (Standard Library)](#venv-(standard-library))
|
| 5 | +- [uv](#uv) |
5 | 6 | - [Pipenv](#pipenv)
|
6 | 7 | - [virtualenv](#virtualenv-package)
|
7 | 8 | - [Poetry](#poetry)
|
@@ -60,6 +61,52 @@ pip install -r requirements.txt`
|
60 | 61 | ```
|
61 | 62 |
|
62 | 63 |
|
| 64 | +## uv |
| 65 | + |
| 66 | +To create a virtual environment in a given directory: |
| 67 | +``` |
| 68 | +$ uv venv |
| 69 | +``` |
| 70 | +If no directory name is provided, the venv will be created in the directory `.venv`. |
| 71 | + |
| 72 | +To activate the virtual environment run: |
| 73 | +``` |
| 74 | +$ .venv/Scripts/activate # on Windows Powershell |
| 75 | +$ source .venv/bin/activate # Unix system |
| 76 | +``` |
| 77 | + |
| 78 | +Installing packages from PyPI: |
| 79 | +``` |
| 80 | +$ uv pip install <package_name> |
| 81 | +``` |
| 82 | + |
| 83 | +Installing from a git repository: |
| 84 | +``` |
| 85 | +$ uv pip install "<package_name> @ https://github.com/<user>/<repo>" |
| 86 | +``` |
| 87 | + |
| 88 | +To list what’s installed in a given venv |
| 89 | +``` |
| 90 | +$ uv pip freeze |
| 91 | +``` |
| 92 | +You can direct the results to a file like: |
| 93 | +``` |
| 94 | +$ uv pip freeze > requeirements.txt |
| 95 | +``` |
| 96 | +The list will have explicit version requirements for each package, meaning it will be “locked” to the specific versions. |
| 97 | + |
| 98 | +If you want to take an existing `pyproject.toml` or `requirements.in` file and generate a locked dependency set as `requirement.txt`, use: |
| 99 | +``` |
| 100 | +$ uv pip compile pyproject.toml -o requirements.txt |
| 101 | +# or |
| 102 | +$ uv pip compile requirements.in -o requirements.txt |
| 103 | +``` |
| 104 | + |
| 105 | +To bring a project’s installed dependencies in sync with a list of locked dependencies use: |
| 106 | +``` |
| 107 | +$ uv pip sync requirements.txt |
| 108 | +``` |
| 109 | + |
63 | 110 | ## Pipenv
|
64 | 111 |
|
65 | 112 | Installing Pipenv: `$ pip install pipenv`
|
|
0 commit comments