Skip to content

Add allow_multiple flag to support multiversion packages#239

Open
dralley wants to merge 1 commit into
prefix-dev:mainfrom
dralley:allow-multiversion
Open

Add allow_multiple flag to support multiversion packages#239
dralley wants to merge 1 commit into
prefix-dev:mainfrom
dralley:allow-multiversion

Conversation

@dralley

@dralley dralley commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Add allow_multiple: bool to Candidates, allowing dependency providers to indicate that multiple versions of a package may coexist in the solution (e.g. kernel packages on RPM systems). When set, the solver skips the at-most-one constraint encoding for that package name.

(multiple co-existing kernels on a system is a common configuration because GRUB can be configured to present previous versions of the kernel as emergency backup boot options)

@dralley dralley force-pushed the allow-multiversion branch from bcf4955 to fb74be5 Compare June 12, 2026 17:02
@dralley

dralley commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

One other example (tbh the only other example I could find) that uses multiversion is gpg-pubkey, a virtual package whose "version" is derived from the fingerprint of a public key trusted by the system package manager.

A different version of gpg-pubkey is created for each trusted public key, and all versions of gpg-pubkey are considered installed simultaneously.

So it's niche but thankfully a simple and unobtrusive feature to implement otherwise.

Comment thread src/solver/encoding.rs
/// see [`Self::forbid_seen`] for why globally-deduplicating is safe.
/// Also skips registration for packages that allow multiple versions.
fn register_forbid_target(&mut self, name_id: D::NameId, variable: VariableId) {
if self.state.allow_multiple_names.contains(name_id) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It likely doesn't matter much but you could probably give the branch predictor a hint here that this path is unlikely to be taken.

Comment thread tests/solver/main.rs Outdated
Comment thread tests/solver/main.rs Outdated
@dralley dralley force-pushed the allow-multiversion branch from fb74be5 to af6260d Compare June 14, 2026 04:06
@dralley dralley marked this pull request as draft June 14, 2026 04:09
@dralley dralley force-pushed the allow-multiversion branch from af6260d to 4f03474 Compare June 15, 2026 22:06
@dralley dralley marked this pull request as ready for review June 15, 2026 22:08
@dralley dralley force-pushed the allow-multiversion branch 2 times, most recently from 3db5a60 to a98bff0 Compare June 15, 2026 22:09
@dralley

dralley commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

OK, these tests ought to be an improvement.

Comment thread tests/solver/main.rs Outdated
///
/// This is actually not ideal, but resolving overlapping ranges to a single common
/// version would require additional optimization in the solver (e.g. soft forbid clauses
/// or a post-solve minimization pass).

@dralley dralley Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I stick to the 70 / 80-width comments? It felt a bit cramped, but that's seemingly the convention in this file.

@dralley dralley force-pushed the allow-multiversion branch 3 times, most recently from f58b78b to 97bf78b Compare June 15, 2026 22:48
Comment thread tests/solver/main.rs
///
/// This is actually NOT ideal - installing only kernel=2 would be optimal - but resolving
/// overlapping ranges to a single common version would require additional optimization in
/// the solver (e.g. soft forbid clauses or a post-solve minimization pass).

@dralley dralley Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notable. I'm not particularly fussed about this at the moment but it is probably worth doing eventually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you want me to do it now.

@dralley dralley force-pushed the allow-multiversion branch from 97bf78b to 3122b8f Compare June 17, 2026 13:51
Add `allow_multiple: bool` to `Candidates`, allowing dependency
providers to indicate that multiple versions of a package may coexist
in the solution (e.g. kernel packages on RPM systems). When set, the
solver skips the at-most-one constraint encoding for that package name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dralley dralley force-pushed the allow-multiversion branch from 3122b8f to 01e7a1d Compare June 17, 2026 13:52
@dralley

dralley commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@baszalmstra Rebased + rewrote the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants