-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
bpo-42856: Add --with-wheel-pkg-dir=PATH configure option #24210
Conversation
This PR is my second attempt which is way less than intrusive. Changes since my first attempt PR #24154:
|
I created a PR on the Fedora python3.10 package to test the integration of my patch: |
@xavfernandez @pradyunsg @pablogsal @kkonopko @hroncok @nanjekyejoannah: Hi, does anyone of you want to review this PR? See https://bugs.python.org/issue42856 for the rationale. (I looked at who modified Lib/ensurepip/ last months.) |
I fixed test_ensurepip when ensurepip._bundled is missing (on Fedora). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not review the non-python files.
The python part seems ok but now feels somewhat complicated.
I wonder if we should not drop _SETUPTOOLS_VERSION
, _PIP_VERSION
& _PROJECTS
variables in favor of using importlib.resources.files
on ensurepip._bundled
to automatically discover the bundled versions (similarly to what is now done with _WHEEL_PKG_DIR
).
This would ease the next pip/setuptools versions bump: all that would be necessary would be to replace the wheels in Lib/ensurepip/_bundled/
without specifying the expected versions.
def test_version(self): | ||
# Test version() | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for not using pathlib
?
self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl") | |
pathlib.Path(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl").touch() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to avoid testing pathlib in test_ensurepip :-) I like low-level code :-D
Sure, that's doable, but can it be done in a following PR? I tried to reduce changes in my PR to focus on the new feature (and reduce any risk of regression). My first PR attempt scanned ensurepip/_bundled/ to discover the version and Python tag of bundled setuptools and pip. It reused the os.listdir() code, but importlib.resources.files sounds like a better idea for bundled wheel packages. |
certainly :) |
I tested manually 3 cases using test_ensurepip. I added logs to see which packages are used with log.patch file:
Case 1: only bundled
=> OK: BUNDLED is used, test_ensurepip pass Case 2: only wheel dir
=> OK: WHEEL DIR is used, test_ensurepip pass Case 3: both, wheel dir + bundled
=> OK: WHEEL DIR is used, test_ensurepip pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I haven't check the configure changes, because I don't understand autotools.)
packages = dir_packages | ||
_PACKAGES = packages | ||
return packages | ||
_PACKAGES = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move this to other constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a constant but a cache for _get_packages(). I prefer to keep it close to the function definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your call. The missing empty line looks weird thou.
) | ||
with open(os.path.join(tmpdir, wheel_name), "wb") as fp: | ||
for name, package in _get_packages().items(): | ||
if package.wheel_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is confusing. What about:
if package.wheel_name: | |
# bundled wheels have names: | |
if package.wheel_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comments inside, is it better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import.
Oops, there is spelling mistake: recommand => recommend. I updated my PR :-) |
Thanks for the reviews @xavfernandez and @hroncok! It's now merged. |
…4210) Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import.
…4210) Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import. backported to 3.8 by Michał Górny
…4210) Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import. backported to 3.9 by Michał Górny
…4210) Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import. backported to 3.8 by Michał Górny
…4210) Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages. Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don't install the ensurepip._bundled package. ensurepip: Remove unused runpy import. backported to 3.9 by Michał Górny
Add --with-wheel-pkg-dir=PATH option to the ./configure script. If
specified, the ensurepip module looks for setuptools and pip wheel
packages in this directory: if both are present, these wheel packages
are used instead of ensurepip bundled wheel packages.
Some Linux distribution packaging policies recommand against bundling
dependencies. For example, Fedora installs wheel packages in the
/usr/share/python-wheels/ directory and don't install the
ensurepip._bundled package.
ensurepip: Remove unused runpy import.
https://bugs.python.org/issue42856