Skip to content
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

Add an UnusableDependencies incompatibility kind and use for conflicting versions #424

Merged
merged 6 commits into from
Nov 16, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Nov 14, 2023

Addresses #309 (comment)

Similar to #338 this throws an error when merging versions results in an empty set. Instead of propagating that error, we capture it and return a new dependency type of Unusable. Unusable dependencies are a new incompatibility kind which includes an arbitrary "reason" string that we present to the user. Adding a new incompatibility kind requires changes to the vendored pubgrub crate.

We could use this same incompatibility kind for conflicting urls as in #284 which should allow the solver to backtrack to another valid version instead of failing (see #425).

Unlike #383 this does not require changes to PubGrub's package mapping model. I think in the long run we'll want PubGrub to accept multiple versions per package to solve this specific issue, but we're interested in it being merged upstream first. This pull request is just using the issue as a simple case to explore adding a new incompatibility type.

We may or may not be able convince them to add this new incompatibility type upstream. As discussed in pubgrub-rs/pubgrub#152, we may want a more general incompatibility kind instead which can be used for arbitrary problems. An upstream pull request has been opened for discussion at pubgrub-rs/pubgrub#153.

Related to:

Comment on lines 121 to 122
set.union(&r),
reason,
Copy link
Member Author

Choose a reason for hiding this comment

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

👀 this is probably not quite right because we shouldn't merge the reasons here

Copy link
Member

Choose a reason for hiding this comment

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

Can you say a bit more about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure it matters, but this merges the two incompatibilities by taking the union of their version ranges and one of the reasons but if the reasons are different we should not merge them because they are distinct incompatibilities. Or.. we could merge them and say "{reason} and {reason}" but that seems unclear later on since you lose the reason for each range.

Copy link
Member

Choose a reason for hiding this comment

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

Or we could make the reason it's own enum with its own merge semantics, but that requires encoding the set of reasons in the PubGrub crate.

)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems generic enough that it could feasibly be upstreamed 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -104,6 +106,17 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
}
}

/// Create an incompatibility to remember
/// that a package version is not selectable
/// because its dependencies are not usable.
Copy link
Member

Choose a reason for hiding this comment

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

The line breaks here make me read this like a haiku 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

Me too haha I just kept the existing style but it's funny

@zanieb
Copy link
Member Author

zanieb commented Nov 15, 2023

I don't understand why the numpy test is failing.

I'm going to look into upstreaming these changes, but I don't think it needs to block us here.

@zanieb zanieb marked this pull request as ready for review November 15, 2023 00:27
@konstin
Copy link
Member

konstin commented Nov 15, 2023

#426 Fixes CI (See #427)

@konstin
Copy link
Member

konstin commented Nov 15, 2023

(fixed the merge conflict i created)

@zanieb
Copy link
Member Author

zanieb commented Nov 15, 2023

An upstream pull request has been opened for discussion at pubgrub-rs/pubgrub#153.

@zanieb
Copy link
Member Author

zanieb commented Nov 16, 2023

While I intend to continue work upstream, I'd like to merge this for my own sanity?

Perhaps we should create a PubGrub fork instead so we can track these changes?

@charliermarsh
Copy link
Member

👍 On setting up our own fork as discussed in our 1:1.

@@ -48,7 +48,7 @@ once_cell = { version = "1.18.0" }
petgraph = { version = "0.6.4" }
platform-info = { version = "2.0.2" }
plist = { version = "1.6.0" }
pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "46f1214fe6b7886709a35d8d2f2c0e1b56433b26" }
pubgrub = { git = "https://github.com/zanieb/pubgrub", rev = "efe34571a876831dacac1cbba3ce5bc358f2a6e7" }
Copy link
Member Author

Choose a reason for hiding this comment

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

@zanieb zanieb enabled auto-merge (squash) November 16, 2023 19:59
@zanieb zanieb merged commit 0d9d4f9 into main Nov 16, 2023
3 checks passed
@zanieb zanieb deleted the zanie/new-incompatibility branch November 16, 2023 20:02
zanieb added a commit that referenced this pull request Nov 17, 2023
Extends #424 with support for URL dependency incompatibilities.

Requires changes to `miette` to prevent URLs from being word wrapped;
accepted upstream in zkat/miette#321
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.

3 participants