Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github URL version dependency not parsed appropriately from setup.py requirement #8197

Closed
NickHilton opened this issue May 6, 2020 · 3 comments

Comments

@NickHilton
Copy link

NickHilton commented May 6, 2020

Environment

  • pip version: 20.1
  • Python version: 3.8.0
  • OS: macOS Catalina

Description
When installing a dependency via a github URL in a setup.py file, the version is not matched and pip does not realise it needs to update the dependency.

Expected behavior
The correct version number should be parsed from the github requirement and pip should realise it needs to upgrade the version

Note: This happens with or without the -U flag

How to Reproduce

  1. Get six package from pip install six==1.13.0 as a test package
  2. Then have setup.py as follows:
from setuptools import setup

setup(
    name='name',
    version='version',
    install_requires=[
        "six@git+https://github.com/benjaminp/six@1.14.0",
    ],
)
  1. Run pip install -e . -U in the main directory
  2. The six package is not updated when it should be

Output

Requirement already satisfied: six@ git+https://github.com/benjaminp/six@1.14.0 from git+https://github.com/benjaminp/six@1.14.0 in site-packages (from name==version) (1.13.0)
  • Note the discrepancy in the version it matched (1.13.0) and the version requested (1.1.4.0)

Notes

  • I tried digging in to this and found that the problem could be stemming from req = REQUIREMENT.parseString(requirement_string) here
  • The parser can't find a specifier in requirement_string == "six@git+https://github.com/benjaminp/six@1.14.0"
  • The output of this line is
req.name == "six"
req.url == "git+https://github.com/benjaminp/six@1.14.0"
req.specifier = ""
  • This means that the SpecifierSet attached to this requirement is empty and pip subsequently does not check for a specific version when seeing if the requirement is satisified
  • One problem here is that the user doesn't necessarily specify a version number in the github URL part, they can specify a branch or a release tag or a commit
    • The only way for pip to check the version is probably to go to the github URL and fetch the version number before checking it later
@uranusjr
Copy link
Member

uranusjr commented May 6, 2020

As you said, the Git tag does not necessarily match the version number. There is no way anyone can know the version, and thus it is not viable to parse the version out of it.

The fact pip installs a different version from your expectation is entirely another issue, unrelated to the version parsing logic. As mentioned in #988 (comment), pip is now shipping a new resolver that would resolve a correct version out of the given specifiers.

@sbidoul
Copy link
Member

sbidoul commented May 6, 2020

See also #7678 and linked issues.

@NickHilton
Copy link
Author

Thanks, the fact theres no version passed through is the real issue, I wasn't really sure how best to phrase it in the title of this issue. Seems like there's two separate paths for making this work - 1 parse out a version from a requirement specified like this, maybe use the tag specified as the 'version' the user required and installed for checking againtst or 2 - Retrieve the version from the URL somehow and use that to determine if a reinstall should happen.

@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Feb 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants