GH-80789: Get rid of the ensurepip infra for many wheels#109245
Conversation
b9fe227 to
6b2ce22
Compare
September 10, 2023 23:33
71911de to
bf909c0
Compare
September 10, 2023 23:36
Sorry, something went wrong.
|
I've taken the liberty of pushing two changes to your branch; feel free to revert in whole or part. Both look to simplify what ensurepip is doing internally -- e.g. with only I've also removed type annotations, as these are ignored and we shouldn't introduce more (tomllib and importlib.resources are special cases). I think there are further simplifications we could make, but I thought this was a reasonable middle-ground -- let me know your thoughts! A |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
LGTM. But I would prefer to get a second review on this one.
Sorry, something went wrong.
pfmoore
left a comment
There was a problem hiding this comment.
One minor comment, but it doesn't block this - feel free to leave it if you think your version is better.
Sorry, something went wrong.
I think annotations contribute to maintainability.
I was specifically avoiding any refactoring in this PR, trying to make it as small as possible and keep the potential conflicts with the rest of related PRs at minimum. I don't like some of the changes but if this gets it merged faster so be it. |
Sorry, something went wrong.
|
FreeBSD failing check reason:
|
Sorry, something went wrong.
I'm pretty sure there's still a policy that we don't use type annotations in the stdlib. |
Sorry, something went wrong.
Interesting.. https://devguide.python.org/search/?q=type+annotations&check_keywords=yes&area=default doesn't return anything related (nor does using Google search against that site). |
Sorry, something went wrong.
See https://discuss.python.org/t/21487; #108125 (comment). Quoting Brett: "It's codified based on discussions among the core developers that we have all agreed to over the years" A |
Sorry, something went wrong.
|
@AA-Turner so I tried something which resulted in some simplification. I used pathlib but also made functions to return paths instead of complex structures with data that is never used together by the callers. I made sure that the coverage of the changed parts is at 100%, while making it less branchy... |
Sorry, something went wrong.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
This is a refactoring change that aims to simplify ``ensurepip``. Before it, this module had legacy infrastructure that made an assumption that ``ensurepip`` would be provisioning more then just a single wheel. That assumption is no longer true since [[1]][[2]][[3]]. In this change, the improvement is done around removing unnecessary loops and supporting structures to change the assumptions to expect only the bundled or replacement ``pip`` wheel. [1]: python@ece20db [2]: python#101039 [3]: python#95299
This change is intended to make it clear that the helper now only returns one package and no more. Co-Authored-By: vstinner@python.org
- Exit early if there are no files in the directory - Return a match early by iterating in reverse order - Merge filename checks - Inline the path variable - Remove type annotations
- Return a dict with consistent fields - Remove caching - Remove type annotations - Leverage the known wheel package dir value to calculate full paths
It provides us with the ability to write simpler high-level logic that is easier to understand. As a side effect, it became possible to make the code less branchy.
It was returning bytes on FreeBSD which was incorrectly injected into the Python code snippet executed in a subprocess and had a b-preffix.
Some code comments and test function names were still referring to the removed function name. Not anymore!
This script is separate and is only used in CI as opposed to runtime.
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
It was tripping the linters and became unnecessary after hardcoding the pip wheel filename prefix in the string.
45f9944 to
2472d87
Compare
January 25, 2024 13:33
|
@pradyunsg there was a merge conflict that I solved with rebase. No other changes made. |
Sorry, something went wrong.
pradyunsg
left a comment
There was a problem hiding this comment.
One last change, but LGTM otherwise!
Sorry, something went wrong.
|
@pradyunsg 🛎 the CI remains green after your branch sync FYI. |
Sorry, something went wrong.
|
@AA-Turner @pradyunsg @vstinner apply the backport labels? |
Sorry, something went wrong.
|
I don't think that such refactoring change should be backported to stable branches. Only bugfixes. |
Sorry, something went wrong.
…ython#109245) Co-authored-by: vstinner@python.org Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com> Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This is a refactoring change that aims to simplify
ensurepip. Before it, this module had legacy infrastructure that made an assumption thatensurepipwould be provisioning more then just a single wheel. That assumption is no longer true since [1][2][3].In this change, the improvement is done around removing unnecessary loops and supporting structures to change the assumptions to expect only the bundled or replacement
pipwheel.This is a spin-off of #12791.