Skip to content
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

Migrate to importlib-metadata #7705

Closed
wants to merge 3 commits into from

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Feb 6, 2020

Progress (probably not fix) #7413.

The plan is to implement a common interface in pip._internal.metadata, and gradually move direct pkg_resources.Distribution to go through it.

@uranusjr uranusjr force-pushed the importlib-metadata branch 3 times, most recently from 87c92ad to 4ef5bba Compare February 6, 2020 09:12
Comment on lines 25 to 26
if MYPY_CHECK_RUNNING:
Distribution = impl.Distribution
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason to not directly assign this, outside of the if?

Comment on lines +9 to +10
-import zipp
+from pip._vendor import zipp
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 be automatically handled by vendoring -- does it not do this?

Comment on lines +18 to +20
-
-
-__version__ = version(__name__)
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reasons to do this?

Copy link
Member Author

@uranusjr uranusjr Feb 26, 2020

Choose a reason for hiding this comment

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

The version function looks for the importlib-metadata distribution itself in sys.path, and breaks with vendoring since there’s no metadata anywhere to be found. I figure it’s easier to remove the global call (which fails on import time) since we have no interest in reading __version__ anyway.

Copy link
Member

@pradyunsg pradyunsg Feb 26, 2020

Choose a reason for hiding this comment

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

A comment describing this somewhere on the patch, would be useful. Instead of removing the lines, consider commenting them out and noting why, similar to how we do it in requests.patch for the simplejson import. :)

Copy link
Member

Choose a reason for hiding this comment

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

Yup, as reminded in #7784 patches should be dcumented/motivated here: https://github.com/pypa/pip/blob/master/src/pip/_vendor/README.rst#modifications

Copy link
Member

@xavfernandez xavfernandez Feb 26, 2020

Choose a reason for hiding this comment

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

And concerning the version value, it might actually be useful if we wanted to include the vendored libraries' version in pip debug output to help diagnose tweaked installation. But that's not currently the case indeed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants