-
Notifications
You must be signed in to change notification settings - Fork 286
Closed
Description
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/repoThis is because the Requirement class currently ensures the URL contains netloc:
packaging/packaging/requirements.py
Lines 114 to 117 in 456f94f
| 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels