-
Notifications
You must be signed in to change notification settings - Fork 3.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
Migrate to importlib-metadata #7705
Conversation
87c92ad
to
4ef5bba
Compare
4ef5bba
to
dbae3ff
Compare
if MYPY_CHECK_RUNNING: | ||
Distribution = impl.Distribution |
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 specific reason to not directly assign this, outside of the if?
-import zipp | ||
+from pip._vendor import zipp |
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 should be automatically handled by vendoring -- does it not do this?
- | ||
- | ||
-__version__ = version(__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.
Any specific reasons to do this?
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.
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.
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.
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. :)
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.
Yup, as reminded in #7784 patches should be dcumented/motivated here: https://github.com/pypa/pip/blob/master/src/pip/_vendor/README.rst#modifications
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.
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.
Progress (probably not fix) #7413.
The plan is to implement a common interface in
pip._internal.metadata
, and gradually move directpkg_resources.Distribution
to go through it.