Skip to content

bpo-37449: Move ensurepip off of pkgutil and to importlib.resources #15109

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

Merged
merged 4 commits into from
Sep 13, 2019

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Aug 4, 2019

Move ensurepip off of pkgutil and to importlib.resources.

https://bugs.python.org/issue37449

Automerge-Triggered-By: @ericsnowcurrently

@nanjekyejoannah
Copy link
Contributor Author

cc @brettcannon @warsaw .

@brettcannon brettcannon self-requested a review August 9, 2019 21:31
Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

I don't see a change in here to add an __init__.py file to Lib/ensurepip/_bundled to make it be a concrete package instead of a namespace package as importlib.resources won't work with the latter. Did you happen to manually test this and have it succeed? Or am I missing something?

import sys
import tempfile
from . import _bundled

from importlib.resources import read_binary
Copy link
Member

Choose a reason for hiding this comment

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

Import to the module, not the object (both to follow the style of the module and because it avoids circular import issues):

Suggested change
from importlib.resources import read_binary
from importlib import resources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC, I was not able to do the import without adding the init.py to make it a package.

import sys
import tempfile
from . import _bundled
Copy link
Member

Choose a reason for hiding this comment

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

PEP 8 says to sort imports so that stdlib imports com first, then a blank line, then package-local modules.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@nanjekyejoannah
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@brettcannon: please review the changes made to this pull request.

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

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

One very minor PEP 8 thing, then this looks ready to go!

import sys
import tempfile

from importlib import resources
Copy link
Member

Choose a reason for hiding this comment

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

This should get moved up with the other stdlib modules above.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@nanjekyejoannah
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@brettcannon: please review the changes made to this pull request.

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

@miss-islington miss-islington merged commit 2ccb50c into python:master Sep 13, 2019
gentoo-bot pushed a commit to gentoo/cpython that referenced this pull request May 21, 2024
gentoo-bot pushed a commit to gentoo/cpython that referenced this pull request Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants