Skip to content

[WIP] bpo-42856: Add --with-wheel-pkg-dir=PATH configure option #24151

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

Closed
wants to merge 2 commits into from
Closed

[WIP] bpo-42856: Add --with-wheel-pkg-dir=PATH configure option #24151

wants to merge 2 commits into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jan 7, 2021

Add --with-wheel-pkg-dir=PATH option to ./configure. If specified,
the :mod:ensurepip module also looks for wheel packages in this
directory, and picks the most recent versions in ensurepip._bundled
and the specified directory.

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.

https://bugs.python.org/issue42856

Add --with-wheel-pkg-dir=PATH option to ./configure. If specified,
the :mod:`ensurepip` module also looks for wheel packages in this
directory, and picks the most recent versions in ensurepip._bundled
and the specified directory.

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.
@vstinner
Copy link
Member Author

vstinner commented Jan 7, 2021

This PR finds wheel packages from multiple directories and picks the most recent version. I'm not sure if it's the best idea: let's discuss that in https://bugs.python.org/issue42856

My current implementation has a regression: it doesn't allow to put ensurepip module in a ZIP archive, it removes the resources.read_binary() call. Also, it makes the common case (--with-wheel-pkg-dir option not used) more complicated: it searchs for the most recent version in ensurepip/_bundled/ directory, rather than keeping hardcoded version strings (_PIP_VERSION and _SETUPTOOLS_VERSION).

Maybe I should leave the current code unchanged, and only use the directory if it's available.

Comment on lines +41 to +52
# Extract '20.2.3' from '20.2.3-py2.py3-none-any.whl'
version = []
part = part.split('-', 1)[0]
for part in part.split('.'):
try:
number = int(part)
except ValueError:
break
version.append(number)
if not version:
# failed to parse the version: ignore the package
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails to parse rc/beta versions or post versions.

Copy link
Member Author

Choose a reason for hiding this comment

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

https://www.python.org/dev/peps/pep-0632/ deprecates distutils.version, so I prefer to avoid it. I am not aware of any alternative in the stdlib: the PEP suggests to use the 3rd party packaging module.

I don't think that we use beta or rc version in ensurepip._bundled version. Is it the case in Fedora?

On Fedora, ensurepip._bundled is not installed, so it doesn't matter in practice :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this only looks into ensurepip._bundled? OK

@vstinner
Copy link
Member Author

I wrote PR #24210 which is simpler and more reliable. I close this PR.

@vstinner vstinner closed this Jan 13, 2021
@vstinner vstinner deleted the ensurepip_dir branch January 13, 2021 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants