Formalize support for VCS-style requirements via PEP 440 #10728
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since 2016, users have been asking for a way to install wheels from a URL, e.g. from Git.
There are two approaches to VCS-style requirements:
git+https://github.com/pypa/pip.git#egg=pip
. This is what most people are familiar with. https://pip.pypa.io/en/stable/reference/pip_install/#vcs-supportpip@ git+https://github.com/pypa/pip.git
.Turns out, ever since we upgraded to Pex 2.0, approach #2 has worked to achieve this goal. But few users knew about it (including us), and approach #1 has continued to not work.
We use setuptools to parse our requirements before passing to Pex. Why? We need to normalize it to, for example, strip comments from
requirements.txt
; and because we need the parsed information to do things like create a module mapping for dependency inference. However,pkg_resources.Requirement.parse()
chokes on Pip's VCS style, and only understands PEP 440.Both the Pip VCS and PEP 440 approaches achieve the same end goal. We could use some custom libraries like https://github.com/sarugaku/requirementslib and https://github.com/davidfischer/requirements-parser to allow for Pip's proprietary format, but that adds new complexity to our project.
Nevertheless, few users are familiar with PEP 440, so we eagerly detect if they're trying to use the Pip style and have a nice error message for how to instead use PEP 440:
Closes #3063.
Additional benefit: doesn't allow
--editable
With Pip VCS-style requirements, it's common to use
-e
or--editable
, which changes how the distribution is downloaded so that the user can make edits to it. That is not sensible in Pants, and we are unlikely to ever support this feature.PEP 440 style does not support
-e
, so, when users migrate to PEP 440, they won't have the opportunity to inadvertently use-e
and for it to not work like they expect.[ci skip-rust]
[ci skip-build-wheels]