Skip to content

Read wheel metadata from wheel directly #7538

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 8 commits into from
Jan 2, 2020

Conversation

chrahunt
Copy link
Member

@chrahunt chrahunt commented Jan 2, 2020

More preliminary work for direct-from-wheel metadata reading. Now instead of reading
metadata from the unpacked wheel files on disk, we read it from a ZipFile which wraps
the wheel file itself.

In order to ensure a compatible implementation, tests pass in each step as we incrementally:

  1. make each function work for both zip and directory
  2. remove directory-based implementation

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

With this parameter we can incrementally update code to rely on the zip
file instead of the unpacked source directory.
Since zips don't typically contain directory entries, we want to
only operate on files. Adding files to the .dist-info tests means we
will be able to reuse them for both cases, while they coexist.
First example of transitioning a directory-aware function to using a
zipfile directly. Since we will not need to maintain the unpacked dir
going forward, we don't need to worry about making wheel_dist_info_dir
"generic", just that the same tests pass for both cases at each commit.

To do this neatly we use pytest.fixture(params=[...]), which
generates a test for each param. Once we've transitioned the
necessary functions we only need to replace the fixture name and remove
the dead code.
Since we don't pass the source dir anymore, we can simplify the tests
and implementation for wheel_dist_info_dir.
Makes it simpler to substitute in zip-derived WHEEL extraction.
Since we don't pass the source directory anymore, remove the tests
and implementation.
This functions as a guard for the rest of our wheel-handling code,
ensuring that we will only get past this point if we have a wheel that
we should be able to handle version-wise.

We return a tuple instead of bundling up the result in a dedicated type
because it's the simplest option. The interface will be easy to update
later if the need arises.
@chrahunt chrahunt added type: refactor Refactoring code skip news Does not need a NEWS file entry (eg: trivial changes) labels Jan 2, 2020
@chrahunt chrahunt force-pushed the refactor/get-metadata-from-zip branch 2 times, most recently from 4a1ef42 to 2f92826 Compare January 2, 2020 03:01
@chrahunt chrahunt changed the title Refactor/get metadata from zip Read wheel metadata from wheel directly Jan 2, 2020
@chrahunt chrahunt marked this pull request as ready for review January 2, 2020 04:33
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@xavfernandez xavfernandez left a comment

Choose a reason for hiding this comment

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

👍

yield make_zip


@pytest.fixture(params=[True, False])
Copy link
Member

Choose a reason for hiding this comment

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

😮 I did not know this was possible ^^

@xavfernandez xavfernandez merged commit a71086e into pypa:master Jan 2, 2020
@chrahunt chrahunt deleted the refactor/get-metadata-from-zip branch January 2, 2020 12:29
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Feb 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 1, 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.

3 participants