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

Use UnusableDependencies for URL dependency conflicts #425

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ indicatif = { version = "0.17.7" }
indoc = { version = "2.0.4" }
itertools = { version = "0.11.0" }
mailparse = { version = "0.14.0" }
miette = { version = "5.10.0" }
# For additional textwrap options: https://github.com/zkat/miette/pull/321
miette = { git = "https://github.com/zkat/miette.git", rev = "fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" }
once_cell = { version = "1.18.0" }
petgraph = { version = "0.6.4" }
platform-info = { version = "2.0.2" }
Expand Down
2 changes: 2 additions & 0 deletions crates/puffin-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ name = "puffin"
path = "src/main.rs"

[dependencies]
textwrap = { version = "0.15.2" }

gourgeist = { path = "../gourgeist" }
install-wheel-rs = { path = "../install-wheel-rs", default-features = false }
pep440_rs = { path = "../pep440-rs" }
Expand Down
10 changes: 10 additions & 0 deletions crates/puffin-cli/src/commands/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ pub(crate) async fn pip_compile(
cache: &Path,
mut printer: Printer,
) -> Result<ExitStatus> {
miette::set_hook(Box::new(|_| {
Copy link
Member Author

Choose a reason for hiding this comment

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

We may want to consider using this elsewhere, but let's start small

Box::new(
miette::MietteHandlerOpts::new()
.break_words(false)
.word_separator(textwrap::WordSeparator::AsciiSpace)
.word_splitter(textwrap::WordSplitter::NoHyphenation)
.build(),
)
}))?;

let start = std::time::Instant::now();

// If the user requests `extras` but does not provide a pyproject toml source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ info:
- pip-compile
- requirements.in
- "--cache-dir"
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpIZhaps
- /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpPPS74q
env:
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpKUYHgL/.venv
VIRTUAL_ENV: /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmplYH9yM/.venv
---
success: false
exit_code: 2
exit_code: 1
----- stdout -----

----- stderr -----
error: Conflicting URLs for package `werkzeug`: git+https://github.com/pallets/[email protected] and https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl
× No solution found when resolving dependencies:
╰─▶ root dependencies are unusable: Conflicting URLs for package `werkzeug`:
- git+https://github.com/pallets/[email protected]
- https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ info:
- pip-compile
- requirements.in
- "--cache-dir"
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpPGmK15
- /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmptRvh60
env:
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpgXUIr9/.venv
VIRTUAL_ENV: /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpNKU4Z0/.venv
---
success: false
exit_code: 2
exit_code: 1
----- stdout -----

----- stderr -----
error: Conflicting URLs for package `werkzeug`: https://files.pythonhosted.org/packages/bd/24/11c3ea5a7e866bf2d97f0501d0b4b1c9bbeade102bb4b588f0d2919a5212/Werkzeug-2.0.1-py3-none-any.whl and https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl
× No solution found when resolving dependencies:
╰─▶ root dependencies are unusable: Conflicting URLs for package `werkzeug`:
- https://files.pythonhosted.org/packages/bd/24/11c3ea5a7e866bf2d97f0501d0b4b1c9bbeade102bb4b588f0d2919a5212/Werkzeug-2.0.1-py3-none-any.whl
- https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl

2 changes: 1 addition & 1 deletion crates/puffin-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum ResolveError {
#[error("~= operator requires at least two release segments: {0}")]
InvalidTildeEquals(pep440_rs::VersionSpecifier),

#[error("Conflicting URLs for package `{0}`: {1} and {2}")]
#[error("Conflicting URLs for package `{0}`:\n- {1}\n- {2}")]
ConflictingUrls(PackageName, String, String),

#[error("Conflicting versions for `{0}`: {1}")]
Expand Down
6 changes: 5 additions & 1 deletion crates/puffin-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,11 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
None,
self.markers,
);
if let Err(err @ ResolveError::ConflictingVersions(..)) = constraints {
if let Err(
err @ (ResolveError::ConflictingVersions(..)
| ResolveError::ConflictingUrls(..)),
) = constraints
{
return Ok(Dependencies::Unusable(Some(err.to_string())));
}
let constraints = constraints?;
Expand Down