Search code examples
pythontox

Using tox with shared code results in double dependency installation which ultimatly downgrades the dependency


I have multiple modules in one repository. Now I would like to test the packaging for each module individually, while they might have dependencies between each other. Luckily I have found the dependency option using {distshare}/} in the documentation.

tox.ini:

[testenv]
deps =
    pytest
    {distshare}/pandas-ml-common-*.zip

Once I run tox it installs the local zip as one would expect. But since the dependency is also listed in the setup.py the module gets replaced by its older version from pypi. And yes you guessed it, this makes the tests fail. How can I avoid the installation from pypi once I have a dependency installed using distshare?

stdout:

(.venv) $ tox
GLOB sdist-make: /pandas-ml-utils/setup.py
py37 recreate: .tox/pandas_ml_common/py37
py37 installdeps: pytest, .tox/distshare/pandas-ml-common-0.2.0.zip
py37 inst: .tox/pandas_ml_common/.tmp/package/1/pandas-ml-utils-0.2.0.zip
py37 installed: cachetools==4.1.1,...,pandas-ml-common==0.1.15,...   <--- here it is again

EDIT: from setup.py:

   packages=find_packages(),
   install_requires=["pandas-ml-common", *open("requirements.txt").read().splitlines()],
   extras_require={
      "dev": open("dev-requirements.txt").read().splitlines(),
   },
   include_package_data=True,

In the requirements.txt are only external dependencies like numpy (everything without version atm).


Solution

  • I would maybe try something like:

    [tox]
    # ...
    
    [testenv]
    deps =
        pytest
        # omit "{distshare}/pandas-ml-common-*.zip"
    commands_pre =
        python -m pip install {distshare}/pandas-ml-common-*.zip
    # ...