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

Refactor wheel info extraction during install #7536

Merged
merged 12 commits into from
Jan 1, 2020

Conversation

chrahunt
Copy link
Member

@chrahunt chrahunt commented Jan 1, 2020

This reorganizes and extracts some shared functionality out of install_unpacked_wheel into separate functions.

In addition to setting us up for extracting metadata directly from wheel files (and installing directly from wheel files), this also:

  1. removes one custom usage of pkg_resources
  2. aligns our extraction of the wheel .dist-info directory for Wheel-Version validation, Path-Is-Purelib determination, and RECORD/INSTALLER installation location (where previously they were using 3 different approaches)
  3. removes an ad-hoc parsing of *.dist-info/WHEEL that was being done for Path-Is-Purelib

Progresses #7413, #6030, and the simplification of wheel builder mentioned in #7483 (comment).

This will let us use the value for later processing.
This will let us re-use the wheel_metadata for other parts of
processing, and by parameterizing checks in terms of metadata we will be
able to substitute in metadata derived directly from the zip.
The _invalidversion_ tests are not applicable to the new function since
we do not use a regex to find the applicable folder.
This will make it easier to transition to the already-determined
dist-info directory and reduces some of our dependence on pkg_resources.

Despite the name, the `egg_info` member is also populated for
.dist-info dirs.

ensure_str uses encoding='utf-8' and errors='strict' for Python 3
by default, which matches the behavior in
`pkg_resources.NullProvider.get_metadata`.
Since retrieval of the .dist-info dir already ensures that a
distribution is found, this reduces responsibility on wheel_metadata and
lets us remove a few tests already covered by the tests for
test_wheel_dist_info_dir_*.
@chrahunt chrahunt added type: refactor Refactoring code skip news Does not need a NEWS file entry (eg: trivial changes) labels Jan 1, 2020
@chrahunt chrahunt changed the title Refactor/extract wheel info functions Refactor wheel info extraction during install Jan 1, 2020
@chrahunt chrahunt marked this pull request as ready for review January 1, 2020 20:35

info_dir_name = canonicalize_name(info_dir)
canonical_name = canonicalize_name(name)
if not info_dir_name.startswith(canonical_name):
Copy link
Member

Choose a reason for hiding this comment

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

nit (and for a follow-up PR): since we have canonicalized everything we might as well check for an exact match
if not info_dir_name[:-len('.dist-info')] == canonical_name
this would catch a messed-up wheel with canonical_name = foobar and info_dir_name = foobar1234.dist-info.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the .dist-info dir also has version, we would need that too.

@chrahunt chrahunt merged commit b2f596b into pypa:master Jan 1, 2020
@chrahunt chrahunt deleted the refactor/extract-wheel-info-functions branch January 1, 2020 22:25
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jan 31, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes) type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants