6

Similar to https://stackoverflow.com/questions/12518499/pip-ignores-dependency-links-in-setup-py

I'm modifying faker in anticipation to an open PR I have open with validators, and I want to be able to test the new dependency i will have.

setup(
    name='Faker',
    ...
    install_requires=[
        "python-dateutil>=2.4",
        "six>=1.10",
        "text-unidecode==1.2",
    ],
    tests_require=[
        "validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0",  # TODO: this will change  # noqa
        "ukpostcodeparser>=1.1.1",
        ...
    ],
    ...
)

python setup.py test refuses to install the 0.13.0 version.

If I move the trouble line up to install_requires=[..] (which SHOULD not be there)

setup(
    name='Faker',
    ...
    install_requires=[
        "python-dateutil>=2.4",
        "six>=1.10",
        "text-unidecode==1.2",
         "validators@https://github.com/kingbuzzman/validators/archive/0.13.0.tar.gz#egg=validators-0.13.0",  # TODO: this will change  # noqa
    ],
    tests_require=[
        "ukpostcodeparser>=1.1.1",
        ...
    ],
    ...
)
  • using pip install -e . everything works great -- the correct version gets installed.
  • using python setup.py develop same issue.

My guess is setuptools/distutils doing something weird -- pip seems to address the issue. My question: how do I fix this?

Problematic code and references can be found here:

Easiest way to see the issue at hand:

docker run -it --rm python:3.7 bash -c "git clone https://github.com/kingbuzzman/faker.git; cd faker; pip install -e .; python setup.py test"

UPDATE: Since this has been fixed, the issue wont be replicated anymore -- all tests will pass

Javier Buzzi
  • 6,296
  • 36
  • 50

1 Answers1

2

Unfortunately, neither setup_requires nor tests_require support URL-based lookup or environment markers from PEP 508 yet. You need to use dependency_links, for example

setup(
    ...
    tests_require=["validators>=0.13.0"],
    dependency_links=['git+https://github.com/kingbuzzman/validators@master#egg=validators-0.13.0'],
)
hoefling
  • 59,418
  • 12
  • 147
  • 194
  • 1
    Glad I could help! – hoefling May 08 '19 at 22:54
  • Very similar problem with a package that's also in pypi, only I need to to install always and it is available as a tar file on a web site (not in a git repo). Using python 3.8 and pip 21.2.4. My setup.py install_requires has `mypackage==70.1.0` and dependency_links has `https://my.company.com/path/to/mypackage-70.1.0.tar.gz#egg=mypackage-70.1.0` Works GREAT as 'pip3 install .' and 'python3 setup.py install` but *tox* version 3.24.4 fails, still searches pypi and fails with "ERROR: Could not find a version that satisfies the requirement". Please suggest what to try for tox, thanks in advance. – chrisinmtown Sep 26 '21 at 10:17
  • @chrisinmtown IIRC `tox` relies on `pip install` underneath, so there shouldn’t be an issue with that. Best is to ask a new question with a [mcve] provided; drop a link to it here in the comments and I‘ll try to help. – hoefling Sep 27 '21 at 07:23
  • @chrisinmtown one wild guess would be that the `tox` env has an old version of `setuptools` installed; this might happen for old versions of Python and the versions bootstrapped by the `venv` module. But of course, without an example this is just a speculation. – hoefling Sep 27 '21 at 07:27
  • Thanks @hoefling I asked a new question at https://stackoverflow.com/questions/69362289 hope I was clear and gave enough detail. – chrisinmtown Sep 28 '21 at 13:04