-
Notifications
You must be signed in to change notification settings - Fork 33
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
Investigate incorporating extras merging into the resolver #14
Comments
I came here to create a ticket for exactly this. Since this existing ticket has the same motivation (extras for pip) and the same high level idea, I'll elaborate here instead. I think an interesting approach could be to provide a way for the provider to indicate that certain identifiers are connected. A rough first draft of what that could look like:
For the pip use case this would mean that The above is not necessarily a concrete proposal for implementation. I have given this quite some thought and I like the general idea, but I have not fully considered the specifics yet. It is more of a PoC proposal in the hopes of moving this discussion forward. If I could get some feedback I'd be willing to spend more time on this. Related to pypa/pip#12095 in the sense that that pull request makes an attempt to improve candidate selection for packages with extras but it falls short when additional constraints on the base package appear transitively, after the first |
Other rough brainstorm ideas I had, but that I think are less interesting than the one above (and less concrete):
|
I’m not sure having candidates recalculated is helpful, since the problem here is we want a requirement ( The derived requirement idea is essentially the same as all the above ideas, but instead of having the hook to provide the information, the relation is directly encoded in the requirement. That could work if the requirement can eagerly derive the information—which is true for the case for extras as it is designed now, but could be less flexible for other use cases such as |
Well, if I understand the current I agree with your assessment of the derived requirement idea, though I am not very familiar with |
Cargo directly merges extras (features in Rust terminology) into existing, already resolved candidates.
https://github.com/rust-lang/cargo/blob/4fbd644bc76e25815a8e3a2189b6430fe69fd0d6/src/cargo/core/resolver/mod.rs#L646-L657
This means the provider needs a way to “talk back” to the resolver “I want to add edges to another node,” which is a departure to the current design, in which all communication is one-sided (the resolver asks, and provider responds). But it would make handling extras more natural, and could help with marker merging (which might require a similar talk-back mechanism).
Another thing to consider is that merging extras could make it harder to answer where exactly does that dependency came from? because all extra dependencies got connected to a common parent, losing context. Cargo handles this by maintaining a separate record of requested features. I guess this eventually is a choice of poison; you gotta introduce the complexity somewhere.
One benefit of not merging extras in the resolver is that the graph becomes strictly insert-only. Once a node is inserted you know how many (out-going) edges it has; it won’t change. Sounds like a nice property, but is it even useful at all in practice?
The text was updated successfully, but these errors were encountered: