Skip to content

Commit 0955b8c

Browse files
committed
docs: Explain use of auto-provisioning for required plugins
Signed-off-by: Stephen Finucane <[email protected]>
1 parent 585e016 commit 0955b8c

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

docs/installation.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Installation
22
============
33

44
As tool
5-
--------
5+
-------
66

77
:pypi:`tox` is a CLI tool that needs a Python interpreter (version 3.9 or higher) to run. We recommend either
8-
:pypi:`pipx` or :pypi:`uv` to install tox into an isolated environment. This has the added benefit that later you'll
8+
:pypi:`pipx` or :pypi:`uv` to install tox into an isolated environment. This has the added benefit that later you'll
99
be able to upgrade tox without affecting other parts of the system. We provide method for ``pip`` too here but we
1010
discourage that path if you can:
1111

@@ -17,7 +17,6 @@ discourage that path if you can:
1717
uv tool install tox
1818
tox --help
1919
20-
2120
.. tab:: pipx
2221

2322
.. code-block:: bash
@@ -40,6 +39,7 @@ discourage that path if you can:
4039

4140
wheel
4241
~~~~~
42+
4343
Installing tox via a wheel (default with pip) requires an installer that can understand the ``python-requires`` tag (see
4444
:pep:`503`), with pip this is version ``9.0.0`` (released in November 2016). Furthermore, in case you're not installing
4545
it via PyPI you need to use a mirror that correctly forwards the ``python-requires`` tag (notably the OpenStack mirrors
@@ -49,19 +49,22 @@ don't do this, or older :gh_repo:`devpi/devpi` versions - added with version ``4
4949

5050
sdist
5151
~~~~~
52+
5253
When installing via a source distribution you need an installer that handles the :pep:`517` specification. In case of
5354
``pip`` this is version ``18.0.0`` or later (released in July 2018). If you cannot upgrade your pip to support this you
5455
need to ensure that the build requirements from :gh:`pyproject.toml <tox-dev/tox/blob/main/pyproject.toml>` are
5556
satisfied before triggering the installation.
5657

5758
via ``setup.py``
5859
----------------
60+
5961
We don't recommend and officially support this method. You should prefer using an installer that supports :pep:`517`
6062
interface, such as pip ``19.0.0`` or later. That being said you might be able to still install a package via this method
6163
if you satisfy build dependencies before calling the installation command (as described under :ref:`sdist`).
6264

6365
latest unreleased
6466
-----------------
67+
6568
Installing an unreleased version is discouraged and should be only done for testing purposes. If you do so you'll need
6669
a pip version of at least ``18.0.0`` and use the following command:
6770

docs/plugins.rst

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
1-
Extending tox
2-
=============
1+
Plugins
2+
=======
3+
4+
Many plugins are available for tox. These include, but are not limited to, the extensions found on the ``tox-dev`` org
5+
on ':gh:`GitHub <tox-dev>`.
6+
7+
Plugins are automatically discovered once from the Python environment that tox itself is installed in. This means that
8+
if tox is installed in an isolated environment (e.g. when installed using :pypi:`pipx` or :pypi:`uv`), the plugin(s)
9+
must be installed in the same environment. To ensure a plugin is always available, you can include the plugin is listed
10+
in :ref:`requires`, which will cause tox to auto-provision a new isolated environment with both tox and the plugin(s)
11+
installed. For example:
12+
13+
.. tab:: TOML
14+
15+
.. code-block:: toml
16+
17+
requires = ["tox>=4", "tox-uv>=1"]
18+
19+
.. tab:: INI
20+
21+
.. code-block:: ini
22+
23+
[tox]
24+
requires =
25+
tox>=4
26+
tox-uv>=1
27+
28+
For more information, refer to :ref:`the user guide <auto-provisioning>`.
29+
30+
Developing your own plugin
31+
--------------------------
32+
33+
The below provides some guidance on how to develop your own plugin for tox. A reference guide to the plugin API can be
34+
found in :doc:`plugins_api`.
335

436
Extensions points
537
~~~~~~~~~~~~~~~~~
@@ -50,20 +82,24 @@ How to apply:
5082

5183
Migration from tox 3
5284
~~~~~~~~~~~~~~~~~~~~
85+
5386
This section explains how the plugin interface changed between tox 3 and 4, and provides guidance for plugin developers
5487
on how to migrate.
5588

5689
``tox_get_python_executable``
57-
-----------------------------
90+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91+
5892
With tox 4 the Python discovery is performed ``tox.tox_env.python.virtual_env.api._get_python`` that delegates the job
5993
to ``virtualenv``. Therefore first `define a new virtualenv discovery mechanism
6094
<https://virtualenv.pypa.io/en/latest/extend.html#python-discovery>`_ and then set that by setting the
6195
``VIRTUALENV_DISCOVERY`` environment variable.
6296

6397
``tox_package``
64-
---------------
98+
^^^^^^^^^^^^^^^
99+
65100
Register new packager types via :func:`tox_register_tox_env <tox.plugin.spec.tox_register_tox_env>`.
66101

67102
``tox_addoption``
68-
-----------------
103+
^^^^^^^^^^^^^^^^^
104+
69105
Renamed to :func:`tox_add_option <tox.plugin.spec.tox_add_option>`.

docs/user_guide.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ you want to do more research, we recommend taking a look at these projects:
382382
- `Invoke <https://www.pyinvoke.org/>`__ is a general-purpose task execution library, similar to Make. Invoke is far
383383
more general-purpose than tox but it does not contain the Python testing-specific features that tox specializes in.
384384

385+
.. _auto-provisioning:
385386

386387
Auto-provisioning
387388
-----------------

0 commit comments

Comments
 (0)