pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.36k stars 2.98k forks source link

Allow ignoring sub-dependencies #12790

Open leorochael opened 6 days ago

leorochael commented 6 days ago

Implement --no-deps-for=pkg to allow ignoring sub-dependencies of specific packages, as opposed to the global --no-deps flag.

The flag is accepted on the command line and in requirements files.

Implemented in both the new and the legacy resolvers.

Also, implemented acceptance of the global --no-deps on the requirements file.

Fixes: #9948

pfmoore commented 6 days ago

-1 on implementing this for the leagcy resolver. We should not be making any changes to that code - it's destined for removal.

Apart from that comment, I've not looked at this PR yet so I won't say anything more right now.

leorochael commented 6 days ago

@pfmoore, I only implemented it on the legacy resolver because it was a one-liner (other than formatting).

It took a lot longer for me to add tests to the legacy resolver to check those changes than the change itself.

Adding a check on the legacy resolver to fail to work with the new option (as has been done to other changes) would have taken the same complexity.

But I'll gladly remove the change to the legacy resolver if that is the consensus. I'll await further comments on this PR before doing that.

leorochael commented 6 days ago

I've fixed the remaining CI errors.

I'd appreciate a review and indication of next steps.

pfmoore commented 6 days ago

Some general comments, intended as a review but they seem to fit better here than in the review screen.

To be honest, I think this PR might be premature, as the behaviour isn't fully defined yet. I'd be very uncomfortable if we simply said that the answers to the above questions was "whatever this PR does, or whatever is simplest to add to this PR".