Skip to content

Commit 3e6f8dd

Browse files
committed
Document virtual environment recreate rules
1 parent fc5ca19 commit 3e6f8dd

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

.codeclimate.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ exclude_patterns:
4545
- "*.yaml"
4646
- "*.rst"
4747
- "*.ini"
48+
- ".gitignore"
49+
- ".codeclimate.yml"
50+
- "CONTRIBUTORS"
51+
- "CODE_OF_CONDUCT.md"
52+
- "LICENSE"
53+
- "MANIFEST.in"
54+
- "pyproject.toml"
55+
- "setup.cfg"

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:target: https://dev.azure.com/toxdev/tox/_build/latest?definitionId=9&branchName=master
99
:alt: Azure Pipelines build status
1010
.. image:: https://api.codeclimate.com/v1/badges/425c19ab2169a35e1c16/test_coverage
11-
:target: https://codeclimate.com/github/tox-dev/tox/test_coverage
11+
:target: https://codeclimate.com/github/tox-dev/tox/code?sort=test_coverage
1212
:alt: Test Coverage
1313
.. image:: https://readthedocs.org/projects/tox/badge/?version=latest&style=flat-square
1414
:target: https://tox.readthedocs.io/en/latest/?badge=latest

docs/changelog/93.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document tox environment recreate rules (:ref:`recreate`) - by :user:`gaborbernat`

docs/example/general.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,45 @@ syntax:
3939
[testenv]
4040
commands = nosetests {posargs:--with-coverage}
4141
42+
.. _recreate:
43+
44+
Dependency changes and tracking
45+
-------------------------------
46+
47+
Creating virtual environments and installing dependencies is a expensive operation.
48+
Therefore tox tries to avoid it whenever possible, meaning it will never perform this
49+
unless it detects with absolute certainty that it needs to perform an update. A tox
50+
environment creation is made up of:
51+
52+
- create the virtual environment
53+
- install dependencies specified inside deps
54+
- if it's a library project (has build package phase), install library dependencies
55+
(with potential extras)
56+
57+
These three steps are only performed once (given they all succeeded). Subsequent calls
58+
that don't detect changes to the traits of that step will not alter the virtual
59+
environment in any way. When a change is detected for any of the steps, the entire
60+
virtual environment is removed and the operation starts from scratch (this is
61+
because it's very hard to determine what would the delta changes would be needed -
62+
e.g. a dependency could migrate from one dependency to another, and in this case
63+
we would need to install the new while removing the old one).
64+
65+
Here's what traits we track at the moment for each steps:
66+
67+
- virtual environment trait is tied to the python path the :conf:`basepython`
68+
resolves too (if this config changes, the virtual environment will be recreated),
69+
- :conf:`deps` sections changes (meaning any string-level change for the entries, note
70+
requirement file content changes are not tracked),
71+
- library dependencies are tracked at :conf:`extras` level (because there's no
72+
Python API to enquire about the actual dependencies in a non-tool specific way,
73+
e.g. setuptools has one way, flit something else, and poetry another).
74+
75+
Whenever you change traits that are not tracked we recommend you to manually trigger a
76+
rebuild of the tox environment by passing the ``-r`` flag for the tox invocation. For
77+
instance, for a setuptools project whenever you modify the ``install_requires`` keyword
78+
at the next run force the recreation of the tox environment by passing the recreate cli
79+
tox flag.
80+
4281
.. _`TOXENV`:
4382

4483
Selecting one or more environments to run tests against

docs/example/nose.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ then run the specified test command.
3232
More examples?
3333
------------------------------------------
3434

35-
You can use and combine other features of ``tox`` with your tox runs,
36-
e.g. :ref:`sphinx checks`. If you figure out some particular configurations
37-
for nose/tox interactions please submit them.
38-
39-
Also you might want to checkout :doc:`general`.
35+
Also you might want to checkout :doc:`general` and :doc:`documentation`.
4036

4137
.. include:: ../links.rst

0 commit comments

Comments
 (0)