diff --git a/Cargo.lock b/Cargo.lock index b2feb3532..289e3c8f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ dependencies = [ "hex", "libc", "memmap2 0.5.10", - "miette", + "miette 5.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "reflink-copy", "serde", "serde_derive", @@ -1791,11 +1791,22 @@ name = "miette" version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "miette-derive 5.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette" +version = "5.10.0" +source = "git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6#fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" dependencies = [ "backtrace", "backtrace-ext", "is-terminal", - "miette-derive", + "miette-derive 5.10.0 (git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6)", "once_cell", "owo-colors", "supports-color", @@ -1818,6 +1829,16 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "miette-derive" +version = "5.10.0" +source = "git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6#fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "mimalloc" version = "0.1.39" @@ -2359,7 +2380,7 @@ dependencies = [ "insta-cmd", "install-wheel-rs", "itertools 0.11.0", - "miette", + "miette 5.10.0 (git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6)", "mimalloc", "pep440_rs 0.3.12", "pep508_rs", @@ -2380,6 +2401,7 @@ dependencies = [ "pyproject-toml", "requirements-txt", "tempfile", + "textwrap", "thiserror", "tikv-jemallocator", "tokio", @@ -3345,7 +3367,7 @@ dependencies = [ "base64 0.21.5", "digest", "hex", - "miette", + "miette 5.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "sha-1", "sha2", diff --git a/Cargo.toml b/Cargo.toml index 20c6f93d3..32f556b07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/crates/puffin-cli/Cargo.toml b/crates/puffin-cli/Cargo.toml index 5a4f2ea9e..b6f1e4533 100644 --- a/crates/puffin-cli/Cargo.toml +++ b/crates/puffin-cli/Cargo.toml @@ -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" } diff --git a/crates/puffin-cli/src/commands/pip_compile.rs b/crates/puffin-cli/src/commands/pip_compile.rs index 7571ff9fc..3a43f8f95 100644 --- a/crates/puffin-cli/src/commands/pip_compile.rs +++ b/crates/puffin-cli/src/commands/pip_compile.rs @@ -47,6 +47,16 @@ pub(crate) async fn pip_compile( cache: &Path, mut printer: Printer, ) -> Result { + miette::set_hook(Box::new(|_| { + 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 diff --git a/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_match.snap b/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_match.snap index f637b4e03..5ceecfff8 100644 --- a/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_match.snap +++ b/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_match.snap @@ -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/werkzeug.git@2.0.0 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/werkzeug.git@2.0.0 + - https://files.pythonhosted.org/packages/ff/1d/960bb4017c68674a1cb099534840f18d3def3ce44aed12b5ed8b78e0153e/Werkzeug-2.0.0-py3-none-any.whl diff --git a/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_mismatch.snap b/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_mismatch.snap index 7550ea5ec..8a71ccae3 100644 --- a/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_mismatch.snap +++ b/crates/puffin-cli/tests/snapshots/pip_compile__conflicting_repeated_url_dependency_version_mismatch.snap @@ -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 diff --git a/crates/puffin-resolver/src/error.rs b/crates/puffin-resolver/src/error.rs index 59f0c6d75..5e32d3b3e 100644 --- a/crates/puffin-resolver/src/error.rs +++ b/crates/puffin-resolver/src/error.rs @@ -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}")] diff --git a/crates/puffin-resolver/src/resolver.rs b/crates/puffin-resolver/src/resolver.rs index 9ce74acef..1a5313d73 100644 --- a/crates/puffin-resolver/src/resolver.rs +++ b/crates/puffin-resolver/src/resolver.rs @@ -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?;