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

Include version constraints in derivation chains #9112

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

charliermarsh
Copy link
Member

Summary

Derivation chains can now include the versions at which a package was requested.

@charliermarsh charliermarsh added the error messages Messaging when something goes wrong label Nov 14, 2024
@@ -327,3 +342,88 @@ pub(crate) fn no_solution_hint(err: uv_resolver::NoSolutionError, help: String)
let report = miette::Report::new(Error { header, err, help });
anstream::eprint!("{report:?}");
}

/// Remove local versions sentinels (`+[max]`) from the interval.
fn strip_sentinel(
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 need to DRY this up with the error reporting in the resolver.

/// The version of the package.
version: Version,
pub version: Version,
/// The constraints applied to the subsequent package in the chain.
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 somewhat confusing but it is the most normalized representation...

@@ -19279,7 +19279,7 @@ fn lock_derivation_chain() -> Result<()> {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

help: `wsgiref` was included because `project==0.1.0` depends on `wsgiref`
help: `wsgiref` was included because `project==0.1.0` depends on `wsgiref (==0.1.2)`
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if the parenthesis are helpful for readability here. Is there a particular reason you went with that approach instead of wsgiref==0.1.2?

Copy link
Member Author

Choose a reason for hiding this comment

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

In prior entries, I want to show both the selected version and the version range -- like django==1.4.0 (>=1.0.0). So it seemed nice to be consistent with the use of parentheses here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it should be like: django v1.4.0 (>=1.0.0)?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are like three different cases to consider in the chain:

  • The first dependency (project==0.1.0, which doesn't have a set of constraints, because it's just attached to the root).
  • Intermediary dependencies (not visible here), which have both a pinned version and a set of constraints, so we want to show both (like, django==1.4.0 (>=1.0.0)).
  • The final dependency (wsgiref (==0.1.2)), which we don't show the version for just to be succinct, but could.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, thanks for explaining. I'm happy with whatever you do here. django v1.4.0 (>=1.0.0) seems easier to understand.

Regarding the root package, we might want to do something more consistent with the resolver reporter

fn format_root_requires(&self, package: &PubGrubPackage) -> Option<String> {
if self.is_workspace() {
if matches!(&**package, PubGrubPackageInner::Root(_)) {
if self.is_single_project_workspace() {
return Some("your project requires".to_string());
}
return Some("your workspace requires".to_string());
}
}
match &**package {
PubGrubPackageInner::Root(Some(name)) => Some(format!("{name} depends on")),
PubGrubPackageInner::Root(None) => Some("you require".to_string()),
_ => None,
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I'd omit the * throughout, I don't think we usually show that to users.

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 kind of into wsgiref was included because project v0.1.0 depends on child>=0.1.0 and child v0.1.4 depends on wsgiref

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually the last one you gave isn't bad either.

Copy link
Member

Choose a reason for hiding this comment

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

Whatever you're more into — we can iterate later if we need to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I went with:

help: `wsgiref` (v0.1.2) was included because `project` (v0.1.0) depends on `child` (v0.1.0) which depends on `wsgiref>=0.1.2`

Base automatically changed from charlie/chain to main November 14, 2024 20:48
@charliermarsh charliermarsh force-pushed the charlie/chain-ii branch 2 times, most recently from 3d37271 to 6b06633 Compare November 15, 2024 02:55
@charliermarsh charliermarsh requested a review from zanieb November 15, 2024 02:55
@charliermarsh charliermarsh marked this pull request as ready for review November 15, 2024 02:55
}
(lower, upper)
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved and restructured to make it public.

@charliermarsh charliermarsh force-pushed the charlie/chain-ii branch 3 times, most recently from af267d0 to 87c15db Compare November 15, 2024 19:36
@charliermarsh charliermarsh enabled auto-merge (squash) November 15, 2024 19:37
@charliermarsh charliermarsh merged commit 8dd095c into main Nov 15, 2024
63 of 64 checks passed
@charliermarsh charliermarsh deleted the charlie/chain-ii branch November 15, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants