Search code examples
pytestpypitox

Is it possible to point tox to pull a dependency from a branch (aka use `pip -e` behind the scenes)?


How to test on py27 and py37 in tox when the py37 changes aren't packaged to pypi

  • The py3.7 compatible changes exist in repo branches.

  • They can be run by hand through pip -e installing them and running pytest without tox.

  • I'd like to move to running them through tox, but I can't figure out the correct string to give the deps list, or perhaps this is done in another way.

Attempted solution:

tox.ini

[tox]
envlist = py27,py37


[testenv:py27]
deps =
    pytest
    pytest-cov
    pytest-mock
    pylint
    ; packages specified by the setup.py cover the other dependencies for py2.7
commands =
    pytest -v


[testenv:py37]
deps =
    pytest
    pytest-cov
    pytest-mock
    pylint
    git+ssh//repo_url/location1.git@branchname_that_supports_py37
    git+ssh//repo_url/location2.git@branchname_that_supports_py37
    git+ssh//repo_url/location3.git@branchname_that_supports_py37
    git+ssh//repo_url/location4.git@branchname_that_supports_py37
    git+ssh//repo_url/location5.git@branchname_that_supports_py37
    git+ssh//repo_url/location6.git@branchname_that_supports_py37
    git+ssh//repo_url/location7.git@branchname_that_supports_py37
    git+ssh//repo_url/location8.git@branchname_that_supports_py37

commands =
    pytest -v

Solution

  • For VCS URLs pip needs to know the name of the package that should be provided with #egg=name:

        git+ssh//repo_url/location1.git@branchname_that_supports_py37#egg=package1
    

    Otherwise your tox.ini looks good. I use the same approach, for example.