builder: entirely prevent work duplication #378
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
utils.scoped_cache
: new decorator, modifying a class to memoize method calls using autogenerated object attributesUnlike
functools.lru_cache
, this ensures the cached data cannot outlive theBuilder
object... and does not require itto be hasheable (incl. its attributes, like
build.{env.IsolatedEnv, ProjectBuilder}
)Not sure I like the name, so I'm definitely open to other suggestions.
builder.prepare.Bob
scoped_cache
, ensuring nothing is ever built more than once (from the sameBuilder
)build
: reuse metadata if it was already builtit shouldn't be done unconditionally, since building metadata may (in the worst case) require building the wheel
metadata_path
: directly extract metadata from the wheelI am leaving this as a draft for now, as I don't think we'll see significant improvement before refactoring the public API:
currently, the builder isn't reused between sdist+wheel, zipapps, and metadata calls (in the PyPI uploader)