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

Invalid requirement error with file URL and named project #10098

Closed
1 task done
jaraco opened this issue Jun 25, 2021 · 1 comment · Fixed by #12300
Closed
1 task done

Invalid requirement error with file URL and named project #10098

jaraco opened this issue Jun 25, 2021 · 1 comment · Fixed by #12300
Labels
project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior

Comments

@jaraco
Copy link
Member

jaraco commented Jun 25, 2021

Description

It's possible to install using a git+file scheme:

$ pip install 'git+file:///Users/jaraco/m/pytest-perf'
...
Installed...

It's also possible to specify the distribution name and extras when installing from a remote git repo:

$ pip install 'pytest-perf@git+https://github.com/jaraco/m/pytest-perf'
...
Installed...

But if one tries to install using a git+file scheme and specify the distribution name, an Invalid requirement error occurs:

$ pip install 'pytest-perf@git+file:///Users/jaraco/m/pytest-perf'
ERROR: Invalid requirement: 'pytest-perf@git+file:///Users/jaraco/m/pytest-perf'
Hint: It looks like a path. File 'pytest-perf@git+file:///Users/jaraco/m/pytest-perf' does not exist.

And thus because of #10097, it's not possible to install a local git repo with extras.

I'd really like for there to be some way to install a package at a given revision with extras:

$ pip install '*[testing]@git+file:path/to/repo@rev'

I need this for pytest-perf in order to compare performance of a package against the main branch.

Expected behavior

Honor the combination of the two syntaxes.

pip version

21.1.2

Python version

3.9.2

OS

macOS 11.4

How to Reproduce

x

Output

No response

Code of Conduct

@jaraco jaraco added type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Jun 25, 2021
jaraco added a commit to jaraco/pytest-perf that referenced this issue Jun 25, 2021
@uranusjr uranusjr removed the S: needs triage Issues/PRs that need to be triaged label Jun 25, 2021
@uranusjr
Copy link
Member

Looks like a deficiency in packaging:

>>> packaging.requirements import Requirement
>>> Requirement('pytest-perf@git+file:///Users/jaraco/m/pytest-perf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "packaging/requirements.py", line 130, in __init__
    raise InvalidRequirement("Invalid URL: {0}".format(req.url))
packaging.requirements.InvalidRequirement: Invalid URL: git+file:///Users/jaraco/m/pytest-perf

Specifically, packaging does not seem to allow non-file: URLs without a netloc. But pip’s VCS URLs aren’t file: (but git+file: in this case) and thus rejected by packaging. Personally I feel packaging’s rules are a bit too restrictive; PEP 508 does not specify what URLs are allowed, so instead of trying to decide it for the user, it should either just return whatever is passed in (and let the user perform additional checks), or allow some customisation on the validation logic.

I will open an issue on packaging linking here.

@uranusjr uranusjr added the project: vendored dependency Related to a vendored dependency label Jun 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants