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). |
|
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 This would ease the next pip/setuptools versions bump: all that would be necessary would be to replace the wheels in |
| def test_version(self): | ||
| # Test version() | ||
| with tempfile.TemporaryDirectory() as tmpdir: | ||
| self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl") |
xavfernandez
Jan 14, 2021
Contributor
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() |
vstinner
Jan 14, 2021
Author
Member
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 |
|
(I haven't check the configure changes, because I don't understand autotools.) |
| packages = dir_packages | ||
| _PACKAGES = packages | ||
| return packages | ||
| _PACKAGES = None |
vstinner
Jan 20, 2021
Author
Member
It's not a constant but a cache for _get_packages(). I prefer to keep it close to the function definition.
| ) | ||
| with open(os.path.join(tmpdir, wheel_name), "wb") as fp: | ||
| for name, package in _get_packages().items(): | ||
| if package.wheel_name: |
hroncok
Jan 20, 2021
Contributor
This is confusing. What about:
| if package.wheel_name: | |
| # bundled wheels have names: | |
| if package.wheel_name: |
|
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 :-) |
75e59a9
into
python:master
|
Thanks for the reviews @xavfernandez and @hroncok! It's now merged. |
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