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

Simplify metadata generation flow, to be a lot more "linear" #7287

Merged

Conversation

pradyunsg
Copy link
Member

This PR takes a lot of steps, to inline InstallRequirement.prepare_metadata into SourceDistribution.prepare_distribution_metadata.

As described in #6607 (comment)

@pradyunsg pradyunsg added type: refactor Refactoring code skip news Does not need a NEWS file entry (eg: trivial changes) labels Nov 3, 2019
@pradyunsg pradyunsg changed the title Refactor/Simplify metadata generation flow Simplify metadata generation flow, to be a lot more "linear" Nov 3, 2019
@pradyunsg
Copy link
Member Author

I expect this to fail CI, since I'm 100% sure tests are directly using prepare_metadata.

@pradyunsg pradyunsg force-pushed the refactor/simplify-metadata-generation-flow branch from 624dc5b to 12a0bbf Compare November 3, 2019 14:10
@chrahunt
Copy link
Member

chrahunt commented Nov 3, 2019

This looks a bit more complicated to me because:

  1. the metadata_directory is not something that we would want exposed externally - just the metadata
  2. it more tightly couples the behavior of InstallRequirement to SourceDistribution

IMO a clearer approach would be to:

  1. break up the arguments that we're passing to basic functions, like metadata_generator and get_metadata_generator, to reduce exposure of InstallRequirement and make them more reusable, or
  2. pull out more functions that would serve as building blocks common to any way we decide to model installation/build (e.g. Centralize setuptools args construction #7175)

@pradyunsg
Copy link
Member Author

I think I broadly agree with you.

The coupling of SourceDistribution and InstallRequirement was definitely something I didn't like while I was doing it but I did it anyway, since I ran outta time and filed the PR.

As for simplifying what actually gets passed into the operations.build functions, I agree. That's the intended follow up, among other things zcto this (i.e. once all the moving around of logic is settled).

A couple of things I'd appreciate inputs on:

  • does 6d86c5f look like a good idea to you?
  • would it make sense to skip the inlining of the logic into SourceDistribution (basically dropping d22a5fa)?

@chrahunt
Copy link
Member

chrahunt commented Nov 3, 2019

Yes and yes, IMO. I would even go so far as to inline generate_metadata where it is called in InstallRequirement and elevate _generate_metadata and _generate_metadata_legacy to non-module-private functions.

As a follow up if those are then refactored to take plain non-InstallRequirement arguments then they become very easy to test and understand.

Why: Based on some more experience from refactoring metadata generation,
it became clear to me that the separation of legacy vs modern codepaths
should happen at lower level than this abstraction.
Why: There isn't any state being maintained, or multiple uses of the
metadata generator for a single requirement. The additional complexity
does not help in any significant manner.
@pradyunsg pradyunsg force-pushed the refactor/simplify-metadata-generation-flow branch from 12a0bbf to 19bf26a Compare November 4, 2019 09:56
@pradyunsg pradyunsg force-pushed the refactor/simplify-metadata-generation-flow branch from 19bf26a to f137aef Compare November 4, 2019 16:03
@chrahunt chrahunt merged commit 8341f87 into pypa:master Nov 6, 2019
@pradyunsg pradyunsg deleted the refactor/simplify-metadata-generation-flow branch November 6, 2019 06:30
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Dec 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 6, 2019
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