mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Wait for distribution metadata with --no-deps
(#1812)
## Summary We still need to wait for the distribution metadata (for direct dependencies), even when resolving with `--no-deps`, since we rely on it to report diagnostics to the user. Closes https://github.com/astral-sh/uv/issues/1801.
This commit is contained in:
parent
19890feb77
commit
c2b75b64d2
2 changed files with 70 additions and 0 deletions
|
@ -832,6 +832,25 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> {
|
|||
PubGrubPackage::Package(package_name, extra, url) => {
|
||||
// If we're excluding transitive dependencies, short-circuit.
|
||||
if self.dependency_mode.is_direct() {
|
||||
// If an extra is provided, wait for the metadata to be available, since it's
|
||||
// still required for reporting diagnostics.
|
||||
if extra.is_some() {
|
||||
// Determine the distribution to lookup.
|
||||
let dist = match url {
|
||||
Some(url) => PubGrubDistribution::from_url(package_name, url),
|
||||
None => PubGrubDistribution::from_registry(package_name, version),
|
||||
};
|
||||
let package_id = dist.package_id();
|
||||
|
||||
// Wait for the metadata to be available.
|
||||
self.index
|
||||
.distributions
|
||||
.wait(&package_id)
|
||||
.instrument(info_span!("distributions_wait", %package_id))
|
||||
.await
|
||||
.ok_or(ResolveError::Unregistered)?;
|
||||
}
|
||||
|
||||
return Ok(Dependencies::Available(DependencyConstraints::default()));
|
||||
}
|
||||
|
||||
|
|
|
@ -3859,3 +3859,54 @@ fn unsupported_scheme() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Resolve a package with `--no-deps`, including a valid extra.
|
||||
#[test]
|
||||
fn no_deps_valid_extra() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("flask[dotenv]")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--no-deps"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --no-deps
|
||||
flask==3.0.0
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Resolve a package with `--no-deps`, including an invalid extra.
|
||||
#[test]
|
||||
fn no_deps_invalid_extra() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
let requirements_in = context.temp_dir.child("requirements.in");
|
||||
requirements_in.write_str("flask[empty]")?;
|
||||
|
||||
uv_snapshot!(context.compile()
|
||||
.arg("requirements.in")
|
||||
.arg("--no-deps"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --no-deps
|
||||
flask==3.0.0
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
warning: The package `flask==3.0.0` does not have an extra named `empty`.
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue