Skip to content

Commit

Permalink
Update tox example 2 to set install_command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirosen committed Jan 27, 2023
1 parent c1ecea6 commit 49e85ab
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,31 @@ isolated_build = true

[testenv]
allowlist_externals = poetry
commands_pre = poetry install --no-root --sync --with test
commands = pytest tests/
install_command =
python -m pip install --no-deps {opts} {packages}
commands_pre =
poetry install --no-root --sync --with test
commands =
pytest tests/

[testenv:style]
skip_install = true
commands_pre = poetry install --no-root --sync --with style
commands_pre =
poetry install --no-root --sync --with style
commands =
flake8 src/
black --check src/

[testenv:typing]
commands_pre = poetry install --no-root --sync --with typing
commands = mypy src/
commands_pre =
poetry install --no-root --sync --with typing
commands =
mypy src/
```

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

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

0 comments on commit 49e85ab

Please sign in to comment.