Skip to content

Commit

Permalink
Allow non-registry dependencies in uv pip list --outdated (#8939)
Browse files Browse the repository at this point in the history
## Summary

Closes #8926.
  • Loading branch information
charliermarsh authored Nov 8, 2024
1 parent 7835ce0 commit 0b4e5cf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
18 changes: 13 additions & 5 deletions crates/uv/src/commands/pip/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ impl<'env> LatestClient<'env> {
package: &PackageName,
index: Option<&IndexUrl>,
) -> anyhow::Result<Option<DistFilename>, 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<DistFilename> = 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::<VersionFiles, rkyv::rancor::Error>(&datum.files)
Expand Down
42 changes: 42 additions & 0 deletions crates/uv/tests/it/pip_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
"})?;

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");
Expand Down

0 comments on commit 0b4e5cf

Please sign in to comment.