python - pip install test dependencies for tox from setup.py -
i made project setuptools
, want test tox
. listed dependencies in variable , added setup()
parameter (tests_require
, extras_require
). project needs install of dependencies listed in tests_require
test pip install
not installing them.
i tried did not work:
install_command = pip install {opts} {packages}[tests]
how can install test dependencies without having manage multiple dependency lists (i.e. having dependencies listed in both test_requirements.txt
, tests_require
variable)?
i've achieved committing slight abuse of extra requirements. there trying extras syntax, tests_require
deps aren't automatically available way.
with setup.py
this:
from setuptools import setup test_deps = [ 'coverage', 'pytest', ] extras = { 'test': test_deps, } setup( # other metadata... tests_require=test_deps, extras_require=extras, )
you can test dependencies installed extras syntax, e.g. project root directory:
$ pip install .[test]
give same syntax tox in tox.ini
, no need adjust default install_command
:
[testenv] commands = {posargs:pytest} deps = .[test]
now don't need maintain dependency list in 2 places, , they're expressed should published package: in packaging metadata instead of requirements.txt
files.
it seems little extras hack is not uncommon.
Comments
Post a Comment