From 0b4e5cffa6f13a1ddefb6b9cc4751814aa8b469b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 8 Nov 2024 09:12:25 -0500 Subject: [PATCH] Allow non-registry dependencies in `uv pip list --outdated` (#8939) ## Summary Closes https://github.com/astral-sh/uv/issues/8926. --- crates/uv/src/commands/pip/latest.rs | 18 ++++++++---- crates/uv/tests/it/pip_list.rs | 42 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/crates/uv/src/commands/pip/latest.rs b/crates/uv/src/commands/pip/latest.rs index 7b2241712e2d..552ea7cfd168 100644 --- a/crates/uv/src/commands/pip/latest.rs +++ b/crates/uv/src/commands/pip/latest.rs @@ -27,12 +27,20 @@ impl<'env> LatestClient<'env> { package: &PackageName, index: Option<&IndexUrl>, ) -> anyhow::Result, uv_client::Error> { + let archives = match self.client.simple(package, index, self.capabilities).await { + Ok(archives) => archives, + Err(err) => { + return match err.into_kind() { + uv_client::ErrorKind::PackageNotFound(_) => Ok(None), + uv_client::ErrorKind::NoIndex(_) => Ok(None), + uv_client::ErrorKind::Offline(_) => Ok(None), + kind => Err(kind.into()), + } + } + }; + let mut latest: Option = None; - for (_, archive) in self - .client - .simple(package, index, self.capabilities) - .await? - { + for (_, archive) in archives { for datum in archive.iter().rev() { // Find the first compatible distribution. let files = rkyv::deserialize::(&datum.files) diff --git a/crates/uv/tests/it/pip_list.rs b/crates/uv/tests/it/pip_list.rs index cc23f3f27a05..6b1c1cd555b1 100644 --- a/crates/uv/tests/it/pip_list.rs +++ b/crates/uv/tests/it/pip_list.rs @@ -189,6 +189,48 @@ fn list_outdated_freeze() { ); } +#[test] +fn list_outdated_git() -> Result<()> { + let context = TestContext::new("3.12"); + + let requirements_txt = context.temp_dir.child("requirements.txt"); + requirements_txt.write_str(indoc::indoc! {r" + iniconfig==1.0.0 + uv-public-pypackage @ git+https://github.com/astral-test/uv-public-pypackage@0.0.1 + "})?; + + uv_snapshot!(context.pip_install() + .arg("-r") + .arg("requirements.txt") + .arg("--strict"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 2 packages in [TIME] + Prepared 2 packages in [TIME] + Installed 2 packages in [TIME] + + iniconfig==1.0.0 + + uv-public-pypackage==0.1.0 (from git+https://github.com/astral-test/uv-public-pypackage@0dacfd662c64cb4ceb16e6cf65a157a8b715b979) + "### + ); + + uv_snapshot!(context.pip_list().arg("--outdated"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + Package Version Latest Type + --------- ------- ------ ----- + iniconfig 1.0.0 2.0.0 wheel + + ----- stderr ----- + "### + ); + + Ok(()) +} + #[test] fn list_editable() { let context = TestContext::new("3.12");