-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Allow plugins to use range requirements by applying constraints to plugin resolution #14058
Allow plugins to use range requirements by applying constraints to plugin resolution #14058
Conversation
Commits are useful to review independently. This still needs a test: ideas welcome. I started to refactor the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have useful feedback from my phone, but constraining the plugin resolve LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thoughts on breaking out the second commit as prework? It's a fairly substantial refactor of code orthogonal to plugins.
Yea, reasonable. |
b649d7c
to
b02028b
Compare
This comment has been minimized.
This comment has been minimized.
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…raints. (#14064) Some callers (#14058) of `PexRequirements` will soon need to be able to specify explicit constraints for building a PEX which are _not_ the global constraints. Additionally, consuming the `constraints` directly as a file (rather than parsing and re-materializing the file) forces whitespace/comment edits to the constraints file to invalidate all resolves ([reported here](pantsbuild/requirements-perf#1 (comment))). To fix this, replace `apply_constraints: bool` (for the global constraints) with an explicit list of constraints. [ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…ement is constrained by the working set. # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
b02028b
to
714a4da
Compare
interpreter_constraints: InterpreterConstraints | None | ||
# Requirement constraints to resolve with. If plugins will be loaded into the global working_set | ||
# (i.e., onto the `sys.path`), then these should be the current contents of the working_set. | ||
constraints: tuple[Requirement, ...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be our PipRequirement
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe...? But it doesn't look like that class does anything right now. cc @benjyw
I think that can wait until the class is differentiated in some way, at which point the type system will be able to guide us through replacement fairly easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to allow you to have optional args like --hash
be preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure... but it doesn't do that right now.
I've added https://www.pantsbuild.org/v2.9/docs/plugins-overview#publishing-a-plugin to document this support. |
Looks great, thanks! |
As described in #14246, #14058 caused plugin loading to run twice when we missed the cache. This was because after loading plugins, the working set has changed, and represents a new set of constraints on plugin loading. While the current behavior is accurate, it isn't useful. Instead, we adjust `PluginResolver` to make the inputs to plugin loading idempotent, even if the outputs cannot be. Fixes #14246. [ci skip-rust]
As discussed in #14053, currently if a plugin uses a range requirement (even if it matches the requirement used by Pants itself), a different version might be chosen than what is already installed in the virtualenv for Pants, triggering a conflict when we try to add it to the working set (i.e.
sys.path
).This change uses the current working set to constrain the plugin resolve, so that plugins with range requirements will choose matching versions from those ranges (if possible). To do that, it consumes #14064 to specify the working set as constraints in the
PluginResolver
.Fixes #14053.
[ci skip-rust]