builder: entirely prevent work duplication#378
Draft
nicoonoclaste wants to merge 4 commits into
Draft
Conversation
Dropped the `settings` parameter, as it couldn't be cached (dict isn't hashable) and wasn't used anyway. If this become an issue, I could special-case the hashing of `dict`s in `scoped_cache` This avoids rebuilds with successive method calls. The results are not meaningful anymore outside a given build's context, and `scoped_cache` ties the cached outputs to the `Builder` object so we cannot leak memory.
Collaborator
Author
I guess I'd also need to inject annotations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 theBuilderobject... 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.Bobscoped_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)