-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Refactor InstallRequirement #5051
Comments
In principle I'm +1 on this. Our internals are private precisely so we have the freedom to do stuff like this. It sounds like a pretty major piece of work, so timing will be important. We'll need to juggle this, PEP 517/518, and the resolver. Maybe have a release for each of them, so that's pip 11, 12, and 13 allocated (in some order or other)? |
Great! ^>^ Somewhere around pip 11 or 12, depending on when PEP 517 work happens. If I have the choice, I'd do that after this refactor, but I don't want it to hold it off -- if someone makes a reviewable change for PEP 517, I'm happy to go ahead with that instead |
@pfmoore is tackling PEP 517, I'll work on this refactor after that and then proceed to the resolver work. The resolver is something that the pipenv maintainers are looking into so the refactoring would serve as a good chance to introduce the needed abstractions. :) |
I'm picking this up now. Wish me luck! 🌈 |
My one piece of advice is to do this incrementally in reviewable PR's so you don't wind up with a giant PR that sits for a long time. This has many, many benefits, like letting people see where you're going, avoiding merge conflicts that are hard to handle, lets people review and comment, etc. |
Yep yep! Definitely will be doing this through a lot of small PRs. |
Current next steps:
The above is mostly just simply moving code around and stuff. Broader "have to look at" things after this:
|
Closing this is favor of #6607. :) |
I've had this cooking in my head for a bit now. These aren't critical path for some feature but this definitely something I want to do to make pip more approachable for new contributors and make it easier to reason about the installation flow. I've hinted this before in #4713 (comment).
The idea is that, eventually, the resolver should consume Requirements, get Candidates during resolution and spew out Distributions. The Distributions would then be operated upon during installation/uninstallation etc, downloading/caching would deal with Candidates, listing/freezing/checking would deal with Distributions. This 3-class model works cleanly for each of these use cases.
Currently, all three "jobs" are served by
InstallRequirement
(and InstallationCandidate :P), and it's sometimes hard to keep track of what's happening since there's a lot of stuff that's happening in that one class.This would result in:
I'm curious what @pypa/pip-committers and others think about this since, all in all, this work would result in changes in about a quarter of pip._internal, in terms of LOC.
What follows is basically the mind-dump for this (from about 4 months back, I think):
InstallationCandidate
toCandidateDistribution
CandidateDistribution
pip._internal.models.requirement.Requirement
- Holds information that is given by the userpackaging.requirements.Requirement
pip._internal.models.candidate.CandidateDistribution
- Holds information fetched from the indexInstallationCandidate
pip._internal.models.distribution.Distribution
- Describing the build, install, uninstall and other related behaviours for different kinds of distributions.pkg_resources.Distribution
?LegacySourceDistribution
(non PEP 518/517)ModernSourceDistribution
(PEP 518/517)WheelDistribution
CandidateDistribution
to aDistribution
objectDistribution
should hold that behaviour, notCandidateDistribution
.The reason I want to use the pip._internal.models is to represent that these are essentially objects representing data stored elsewhere that would be operated upon and isn't that what models are, in some sense? :P
PS: This is after I am done with zazo and then bringing it in. zazo is the project where I'm making the resolver.
The text was updated successfully, but these errors were encountered: