Skip to content

Decouple finding, processing, and saving files when installing wheels #8545

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

Closed
wants to merge 14 commits into from

Conversation

chrahunt
Copy link
Member

@chrahunt chrahunt commented Jul 5, 2020

In order to install files directly from a wheel, we are required to read the files and file attributes from the zip and write them to disk. Previously, our logic related to saving files was mixed up in our logic for filtering files and editing installed files. All of this was packed into clobber, which was called from 2 places with varying arguments.

Now clobber is gone. The responsibility for finding files has been extracted into files_to_process and simplified. Filtering files and editing files has been moved to the 1 place we actually needed to do it, and saving files has been isolated into its own method.

In a later PR we can adapt files_to_process to read from the wheel zip and File.save to extract file attributes and data from the wheel zip, which should be the last two blockers for this capability.

Progresses #6030.

chrahunt added 6 commits July 5, 2020 12:57
We will already create the parent directories for any files that we want
to install, so making sure the destination exists should not be
required.
This simplifies the relationship between the loop body and the "get
files" section at the top of the loop, making it easier to refactor.
Separating the concerns of "get files to process" and "operate
on the files" enforces that there are no dependencies between these
parts of `clobber` and will let us extract the "get files to process"
out of `clobber` and customize it for each use case.
That just made the previous diff cleaner.
This makes the interface between the file-generating function and the
rest of clobber easier to understand, and will act as a type we can pass
around and wrap to reduce the caller-specific processing we currently
do.
Separating generating the files from operating on them will let us be
more explicit about what features of extracted files we depend on, and
clean up some of our logic by making them less caller-specific.
@chrahunt chrahunt added type: refactor Refactoring code skip news Does not need a NEWS file entry (eg: trivial changes) labels Jul 5, 2020
@chrahunt chrahunt changed the title Refactor clobber 2 Decouple finding files, processing files, and saving files when installing wheels Jul 5, 2020
@chrahunt chrahunt changed the title Decouple finding files, processing files, and saving files when installing wheels Decouple finding, processing, and saving files when installing wheels Jul 5, 2020
@chrahunt chrahunt marked this pull request as ready for review July 5, 2020 19:18
chrahunt added 8 commits July 5, 2020 15:23
This will let us refactor the existing logic as a composition of
behaviors, so later changes to read from a zip file directly will be
less impactful.
No caller actually checks for None, so just return False.
This makes `clobber` much simpler, and aligns the interface of
root_scheme files and data_scheme files, so we can process them in the
same way.
This reduces coupling between is_entrypoint_wrapper and the file
generation step, and we'll be able to reuse it for processing on files.
Since this is the only place this parameter is used, we can inline the
filtering directly.
This lets us get rid of our custom list comprehension in favor of the
lazy filter builtin.
This refactoring makes it so that the individual contributors to the
files we need to handle can be broken into their own separate functions,
similar to the approach we took for console scripts.
@chrahunt chrahunt force-pushed the refactor-clobber-2 branch from 35c701a to ad0f7b9 Compare July 5, 2020 19:23
@chrahunt chrahunt marked this pull request as draft July 5, 2020 22:56
@chrahunt
Copy link
Member Author

chrahunt commented Jul 9, 2020

Superseded by #8562.

@chrahunt chrahunt closed this Jul 9, 2020
@chrahunt chrahunt deleted the refactor-clobber-2 branch July 9, 2020 01:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

1 participant