|
5 | 5 | [](https://github.com/tox-dev/tox-uv/actions/workflows/check.yaml) |
6 | 6 | [](https://pepy.tech/project/tox-uv) |
7 | 7 |
|
8 | | -**tox-uv** is a tox plugin which replaces virtualenv and pip with uv in your tox environments. Note that you will get |
9 | | -both the benefits (performance) or downsides (bugs) of uv. |
| 8 | +**tox-uv** is a `tox` plugin, which replaces `virtualenv` and pip with `uv` in your `tox` environments. Note that you |
| 9 | +will get both the benefits (performance) or downsides (bugs) of `uv`. |
10 | 10 |
|
11 | 11 | <!--ts--> |
12 | 12 |
|
13 | 13 | - [How to use](#how-to-use) |
14 | | -- [Configuration](#configuration) |
15 | | - - [uv.lock support](#uvlock-support) |
| 14 | +- [tox environment types provided](#tox-environment-types-provided) |
| 15 | +- [uv.lock support](#uvlock-support) |
| 16 | + - [extras](#extras) |
| 17 | + - [with_dev](#with_dev) |
| 18 | + - [External package support](#external-package-support) |
| 19 | +- [Environment creation](#environment-creation) |
16 | 20 | - [uv_seed](#uv_seed) |
17 | | - - [uv_resolution](#uv_resolution) |
18 | 21 | - [uv_python_preference](#uv_python_preference) |
| 22 | +- [Package installation](#package-installation) |
| 23 | + - [uv_resolution](#uv_resolution) |
19 | 24 | <!--te--> |
20 | 25 |
|
21 | 26 | ## How to use |
22 | 27 |
|
23 | | -Install `tox-uv` into the environment of your tox and it will replace virtualenv and pip for all runs: |
| 28 | +Install `tox-uv` into the environment of your tox, and it will replace `virtualenv` and `pip` for all runs: |
24 | 29 |
|
25 | 30 | ```bash |
26 | | -python -m pip install tox-uv |
27 | | -python -m tox r -e py312 # will use uv |
| 31 | +uv tool install tox --with tox-uv # use uv to install |
| 32 | +tox --version # validate you are using the installed tox |
| 33 | +tox r -e py312 # will use uv |
28 | 34 | ``` |
29 | 35 |
|
30 | | -## Configuration |
| 36 | +## tox environment types provided |
| 37 | + |
| 38 | +This package will provide the following new tox environments: |
31 | 39 |
|
32 | 40 | - `uv-venv-runner` is the ID for the tox environments [runner](https://tox.wiki/en/4.12.1/config.html#runner) for |
33 | | - environments not using lock file. |
| 41 | + environments not using a lock file. |
34 | 42 | - `uv-venv-lock-runner` is the ID for the tox environments [runner](https://tox.wiki/en/4.12.1/config.html#runner) for |
35 | | - environments using `uv.lock` (note we cannot detect the presence of the `uv.lock` file to enable this because that |
| 43 | + environments using `uv.lock` (note we can’t detect the presence of the `uv.lock` file to enable this because that |
36 | 44 | would break environments not using the lock file - such as your linter). |
37 | 45 | - `uv-venv-pep-517` is the ID for the PEP-517 packaging environment. |
38 | 46 | - `uv-venv-cmd-builder` is the ID for the external cmd builder. |
39 | 47 |
|
40 | | -### uv.lock support |
| 48 | +## uv.lock support |
41 | 49 |
|
42 | 50 | If you want for a tox environment to use `uv sync` with a `uv.lock` file you need to change for that tox environment the |
43 | | -`runner` to `uv-venv-lock-runner`. Furthermore, should in such environments you can use the `extras` config to instruct |
44 | | -`uv` to also install the specified extras, for example: |
| 51 | +`runner` to `uv-venv-lock-runner`. Furthermore, should in such environments you use the `extras` config to instruct `uv` |
| 52 | +to install the specified extras, for example: |
45 | 53 |
|
46 | 54 | ```ini |
47 | 55 |
|
@@ -79,32 +87,57 @@ In this example: |
79 | 87 | `test` and `type` extra groups. |
80 | 88 |
|
81 | 89 | Note that when using `uv-venv-lock-runner`, _all_ dependencies will come from the lock file, controlled by `extras`. |
82 | | -Therefore, options like `deps` are ignored. |
| 90 | +Therefore, options like `deps` are ignored (and all others |
| 91 | +[enumerated here](https://tox.wiki/en/stable/config.html#python-run) as Python run flags). |
83 | 92 |
|
84 | | -### uv_seed |
| 93 | +### `extras` |
85 | 94 |
|
86 | | -This flag, set on a tox environment level, controls if the created virtual environment injects pip/setuptools/wheel into |
87 | | -the created virtual environment or not. By default, is off. You will need to set this if you have a project that uses |
88 | | -the old legacy editable mode, or your project does not support the `pyproject.toml` powered isolated build model. |
| 95 | +A list of string that selects, which extra groups you want to install with `uv sync`. By default, it is empty. |
89 | 96 |
|
90 | | -### uv_resolution |
| 97 | +### `with_dev` |
91 | 98 |
|
92 | | -This flag, set on a tox environment level, informs uv of the desired [resolution strategy]: |
| 99 | +A boolean flag to toggle installation of the `uv` development dependencies. By default, it is false. |
93 | 100 |
|
94 | | -- `highest` - (default) selects the highest version of a package that satisfies the constraints |
95 | | -- `lowest` - install the **lowest** compatible versions for all dependencies, both **direct** and **transitive** |
96 | | -- `lowest-direct` - opt for the **lowest** compatible versions for all **direct** dependencies, while using the |
97 | | - **latest** compatible versions for all **transitive** dependencies |
| 101 | +### External package support |
98 | 102 |
|
99 | | -This is a uv specific feature that may be used as an alternative to frozen constraints for test environments, if the |
100 | | -intention is to validate the lower bounds of your dependencies during test executions. |
| 103 | +Should tox be invoked with the [`--installpkg`](https://tox.wiki/en/stable/cli_interface.html#tox-run---installpkg) flag |
| 104 | +(the argument **must** be either a wheel or source distribution) the sync operation will run with `--no-install-project` |
| 105 | +and `uv pip install` will be used afterward to install the provided package. |
101 | 106 |
|
102 | | -[resolution strategy]: https://github.com/astral-sh/uv/blob/0.1.20/README.md#resolution-strategy |
| 107 | +## Environment creation |
| 108 | + |
| 109 | +We use `uv venv` to create virtual environments. This process can be configured with the following options: |
| 110 | + |
| 111 | +### `uv_seed` |
103 | 112 |
|
104 | | -### uv_python_preference |
| 113 | +This flag, set on a tox environment level, controls if the created virtual environment injects `pip`, `setuptools` and |
| 114 | +`wheel` into the created virtual environment or not. By default, it is off. You will need to set this if you have a |
| 115 | +project that uses the old legacy-editable mode, or your project doesn’t support the `pyproject.toml` powered isolated |
| 116 | +build model. |
105 | 117 |
|
106 | | -This flag, set on a tox environment level, controls how uv select the Python interpreter. |
| 118 | +### `uv_python_preference` |
107 | 119 |
|
108 | | -By default, uv will attempt to use Python versions found on the system and only download managed interpreters when |
109 | | -necessary. However, It's possible to adjust uv's Python version selection preference with the |
| 120 | +This flag, set on a tox environment level, controls how `uv` select the Python interpreter. |
| 121 | + |
| 122 | +By default, `uv` will attempt to use Python versions found on the system and only download managed interpreters when |
| 123 | +necessary. However, It is possible to adjust `uv`'s Python version selection preference with the |
110 | 124 | [python-preference](https://docs.astral.sh/uv/concepts/python-versions/#adjusting-python-version-preferences) option. |
| 125 | + |
| 126 | +## Package installation |
| 127 | + |
| 128 | +We use `uv pip` to install packages into the virtual environment. The behavior of this can be configured via the |
| 129 | +following options: |
| 130 | + |
| 131 | +### `uv_resolution` |
| 132 | + |
| 133 | +This flag, set on a tox environment level, informs `uv` of the desired [resolution strategy]: |
| 134 | + |
| 135 | +- `highest` - (default) selects the highest version of a package satisfying the constraints. |
| 136 | +- `lowest` - install the **lowest** compatible versions for all dependencies, both **direct** and **transitive**. |
| 137 | +- `lowest-direct` - opt for the **lowest** compatible versions for all **direct** dependencies, while using the |
| 138 | + **latest** compatible versions for all **transitive** dependencies. |
| 139 | + |
| 140 | +This is an `uv` specific feature that may be used as an alternative to frozen constraints for test environments if the |
| 141 | +intention is to validate the lower bounds of your dependencies during test executions. |
| 142 | + |
| 143 | +[resolution strategy]: https://github.com/astral-sh/uv/blob/0.1.20/README.md#resolution-strategy |
0 commit comments