Respect `--no-sources` in PEP 723 scripts (#7409)

## Summary

Just an oversight.
This commit is contained in:
Charlie Marsh 2024-09-15 12:55:38 -04:00 committed by GitHub
parent e07281deb3
commit 19868455c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 8 deletions

View File

@ -14,7 +14,7 @@ use tracing::{debug, warn};
use uv_cache::Cache;
use uv_cli::ExternalCommand;
use uv_client::{BaseClientBuilder, Connectivity};
use uv_configuration::{Concurrency, ExtrasSpecification, InstallOptions};
use uv_configuration::{Concurrency, ExtrasSpecification, InstallOptions, SourceStrategy};
use uv_distribution::LoweredRequirement;
use uv_fs::{PythonExt, Simplified, CWD};
use uv_installer::{SatisfiesResult, SitePackages};
@ -175,13 +175,16 @@ pub(crate) async fn run(
if let Some(dependencies) = script.metadata.dependencies {
// // Collect any `tool.uv.sources` from the script.
let empty = BTreeMap::default();
let script_sources = script
.metadata
.tool
.as_ref()
.and_then(|tool| tool.uv.as_ref())
.and_then(|uv| uv.sources.as_ref())
.unwrap_or(&empty);
let script_sources = match settings.sources {
SourceStrategy::Enabled => script
.metadata
.tool
.as_ref()
.and_then(|tool| tool.uv.as_ref())
.and_then(|uv| uv.sources.as_ref())
.unwrap_or(&empty),
SourceStrategy::Disabled => &empty,
};
let script_path = std::path::absolute(script.path)?;
let script_dir = script_path.parent().expect("script path has no parent");