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

Unable to specify a VCS-via-file URL #412

Closed
uranusjr opened this issue Mar 21, 2021 · 2 comments
Closed

Unable to specify a VCS-via-file URL #412

uranusjr opened this issue Mar 21, 2021 · 2 comments

Comments

@uranusjr
Copy link
Member

Say I have a Git repoitory locally on /path/to/repo, it is currently not possible to specify a package in it:

>>> from packaging.requirements import Requirement
>>> Requirement("mypackage @ git+file:///path/to/repo")
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:///path/to/repo

This is because the Requirement class currently ensures the URL contains netloc:

elif not (parsed_url.scheme and parsed_url.netloc) or (
not parsed_url.scheme and not parsed_url.netloc
):
raise InvalidRequirement(f"Invalid URL: {req.url}")

IMO the class should not perform any validation, since PEP 508 does not in any restrict what qualifies as a URL, and any decision on what URLs to support falls entirely on the caller. At the very least, it should allow the caller to provide a custom validator.

@sbidoul
Copy link
Member

sbidoul commented Mar 21, 2021

Yeah, that's an oldie: #264.

@uranusjr
Copy link
Member Author

🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants