Skip to content

Commit 0e358f1

Browse files
committed
Update tox example 2 to set install_command
As suggested by @finswimmer, use `install_command = ...` to pass `--no-deps` to pip in the second tox usage example. This skips an unnecessary step in which pip installs dependencies which poetry will then handle in the sync step. Additionally, normalize the style of commands a bit in the proposed update to Usecase 2. Commands are no longer inlined with the config key, which makes the example slightly longer, but also more consistent with the other examples.
1 parent 83d87ab commit 0e358f1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

docs/faq.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,31 @@ isolated_build = true
8282

8383
[testenv]
8484
allowlist_externals = poetry
85-
commands_pre = poetry install --no-root --sync --with test
86-
commands = pytest tests/
85+
install_command =
86+
python -m pip install --no-deps {opts} {packages}
87+
commands_pre =
88+
poetry install --no-root --sync --with test
89+
commands =
90+
pytest tests/
8791

8892
[testenv:style]
8993
skip_install = true
90-
commands_pre = poetry install --no-root --sync --with style
94+
commands_pre =
95+
poetry install --no-root --sync --with style
9196
commands =
9297
flake8 src/
9398
black --check src/
9499

95100
[testenv:typing]
96-
commands_pre = poetry install --no-root --sync --with typing
97-
commands = mypy src/
101+
commands_pre =
102+
poetry install --no-root --sync --with typing
103+
commands =
104+
mypy src/
98105
```
99106

100-
`tox` will create an `sdist` package of the project and uses `pip` to install it in a fresh environment.
101-
Thus, dependencies are resolved by `pip` in the first place. But afterwards we run Poetry,
102-
which will install the locked dependencies into the environment.
107+
`tox` will create an `sdist` package of the project and uses `pip` to install it in a fresh environment,
108+
but because `--no-deps` is used, `pip` will not resolve any dependencies.
109+
Afterwards we run Poetry, which will install the locked dependencies into the environment.
103110

104111
In the `style` testenv, `tox` will only create the virtual environment, and
105112
again we will rely on Poetry to install requirements. The project itself will

0 commit comments

Comments
 (0)