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

Add support for "yanked" files (PEP 592) #6647

Merged
merged 3 commits into from
Jun 27, 2019

Conversation

cjerdonek
Copy link
Member

Fixes #6633.

@cjerdonek cjerdonek added C: dependency resolution About choosing which dependencies to install C: download About fetching data from PyPI and other sources type: enhancement Improvements to functionality labels Jun 25, 2019
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wohoo! @cjerdonek Thanks for picking this up! :D

I'd prefer if we model this a little differently -- part of this is from the PoV that when we do have backtracking resolution, we'd want an order of preference, rather than just a single choice as returned currently. CandidateEvaluator / FoundCandidates are a perfect model for that as it stands IMO, so I'd like to keep it that way. :)

We should filter the items in case of allow_yanked=False, in iter_applicable(). In _sort_key, we should move yanked releases to the end of the sorted list. That way, get_best_candidate can change to return sorted_candidates[0] / None if no candidates match -- or go back to max.

Yes, this splits the responsibility of handling yanked releases, across two classes but I feel that is justified since CandidateEvaluator should only hold the logic for "which is best" and FoundCandidates should hold the logic for "which are allowed/OK".

Thoughts welcome as always. :)


aside: About the sorted call in get_best_candidate -- As it stands, I'd figured it's easy to modify it to simply expose the sorted list of candidates from CandidateEvaluator, instead of the best candidate. The backtracking resolver will want a sequence of candidates by order of preference, so if we're making the change of storing the sorted list and then "choosing" the best, it'd probably be worthwhile to put the "sort this candidate list" in a method that we can start adding tests for it eagerly. I'm okay to defer that to later and go back to the max call for now (there's no hurry and it'd be a good task for new contributors too FWIW).

src/pip/_internal/commands/list.py Outdated Show resolved Hide resolved
tests/unit/test_index.py Outdated Show resolved Hide resolved
src/pip/_internal/index.py Outdated Show resolved Hide resolved
tests/unit/test_index.py Show resolved Hide resolved
src/pip/_internal/index.py Outdated Show resolved Hide resolved
src/pip/_internal/index.py Outdated Show resolved Hide resolved
Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and clear as usual 👍
Maybe a more functional test could be added with a fake index (something like https://github.com/pypa/pip/tree/master/tests/data/indexes)

src/pip/_internal/index.py Outdated Show resolved Hide resolved
src/pip/_internal/index.py Outdated Show resolved Hide resolved
@pradyunsg
Copy link
Member

Nice and clear as usual 👍

+1

I don't say this often enough -- your PRs are super smooth to review @cjerdonek! :D

@xavfernandez
Copy link
Member

In _sort_key, we should move yanked releases to the end of the sorted list. That way, get_best_candidate can change to return sorted_candidates[0] / None if no candidates match -- or go back to max.

👍 I did not like the need to sort the whole list but could not figure a clean way to do that 🤦‍♂️ .

We should filter the items in case of allow_yanked=False, in iter_applicable()

It crossed my mind, but was uncomfortable with the fact that allow_yanked would be used in two places.
But your arguments are sound and I've no simple alternative that crosses my mind 🤷‍♂️

@cjerdonek
Copy link
Member Author

In _sort_key, we should move yanked releases to the end of the sorted list.

Awesome suggestion! Thanks for pointing that out. My mind was thinking of a related PR, so I missed that way of thinking about it.

@cjerdonek
Copy link
Member Author

Thanks, @pradyunsg and @xavfernandez for the great suggestions and quick reviews. I just pushed an updated PR that I think incorporates all of your suggestions. I also think the PR and tests have become simpler due to @pradyunsg's suggestion on sorting vs. filtering.

The only thing missing is a more functional / end-to-end test as @xavfernandez suggested, but I can start thinking about how to do that.

src/pip/_internal/index.py Show resolved Hide resolved
tests/unit/test_index.py Show resolved Hide resolved
@cjerdonek
Copy link
Member Author

Since @xavfernandez and @pradyunsg both approved this, and because the other approach / refactor we started discussing (re: filtering out yanked files earlier in the allow_yanked=False case) isn't trivial, it's probably best to address that in a follow-on PR or PR's. That would also let us discuss and experiment a bit more, without holding up the bulk of things. The more functional, end-to-end test that @xavfernandez mentioned is something else that could go in either as part of that or in another follow-on PR, especially since a higher-level test would be more useful / needed with the other approach. (And there is already quite a number of tests added in this PR.)

@cjerdonek cjerdonek merged commit fc46a18 into pypa:master Jun 27, 2019
@cjerdonek cjerdonek deleted the issue-6633-yanked-releases branch June 27, 2019 07:52
@pradyunsg
Copy link
Member

Sounds good to me! :)

@cjerdonek
Copy link
Member Author

Thanks again, @pradyunsg and @xavfernandez for your good suggestions and reviews!

@pradyunsg
Copy link
Member

Just a minor process thing -- it'd be great if you could file issues for the follow ups to be made here, the end-to-end test as well as the filtering discussion! :)

Thanks for doing this @cjerdonek!

@cjerdonek
Copy link
Member Author

Done here (#6653) and here (#6654).

@pradyunsg
Copy link
Member

pradyunsg commented Jun 27, 2019

Yay! :)

Thanks for doing this @cjerdonek!

With the power of re-reading, a minor clarification: this = this PR; not the issues. But, but, but thanks for making them @cjerdonek! Much appreciated! :)

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jul 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: dependency resolution About choosing which dependencies to install C: download About fetching data from PyPI and other sources type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for yanked files from a repository (PEP 592)
3 participants