Allow non-registry dependencies in `uv pip list --outdated` (#8939)

## Summary

Closes https://github.com/astral-sh/uv/issues/8926.
This commit is contained in:
Charlie Marsh 2024-11-08 09:12:25 -05:00 committed by GitHub
parent 7835ce0c4e
commit 0b4e5cffa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 5 deletions

View File

@ -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)

View File

@ -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");