Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setup.py ignores full path dependencies, instead looks for "best match" in pypi

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:

  • https://github.com/kingbuzzman/faker/commit/20f69082714fae2a60d356f4c63a061ce99a975e#diff-2eeaed663bd0d25b7e608891384b7298R72
  • https://github.com/kingbuzzman/faker
  • https://gist.github.com/kingbuzzman/e3f39ba217e2c14a9065fb14a502b63d
  • https://github.com/pypa/setuptools/issues/1758

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

like image 557
Javier Buzzi Avatar asked May 08 '19 17:05

Javier Buzzi


People also ask

Is setup py outdated?

py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).

What is Install_requires in setup py?

install_requires is a section within the setup.py file in which you need to input a list of the minimum dependencies needed for a project to run correctly on the target operating system (such as ubuntu). When pip runs setup.py, it will install all of the dependencies listed in install_requires.

How does pip use setup py?

If you use setup.py , you have to visit the library's website, figure out where to download it, extract the file, run setup.py ... In contrast, pip will automatically search the Python Package Index (PyPi) to see if the package exists there, and will automatically download, extract, and install the package for you.

Does pip need setup py?

As a first step, pip needs to get metadata about a package (name, version, dependencies, and more). It collects this by calling setup.py egg_info . The egg_info command generates the metadata for the package, which pip can then consume and proceed to gather all the dependencies of the package.


1 Answers

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'],
)
like image 171
hoefling Avatar answered Oct 29 '22 21:10

hoefling