setup.py ignores full path dependencies, instead l

2019-06-22 18:47发布

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

1条回答
We Are One
2楼-- · 2019-06-22 19:34

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'],
)
查看更多
登录 后发表回答