Add --no-sources-package (#14910)
I needed this for a test, e.g., to disable a source for an extra build dependency without disabling the source for a workspace member, and had also seen some requests for it. I think it makes sense to allow this. The refactor is fairly mechanical, we go from `SourceStrategy::Enabled|Disabled` to `NoSources::All|None|Package(names)` as we do for other options like `NoBinary`. Related https://github.com/astral-sh/uv/issues/17441
This commit is contained in:
@@ -88,7 +88,7 @@ mod resolver {
|
||||
|
||||
use uv_cache::Cache;
|
||||
use uv_client::RegistryClient;
|
||||
use uv_configuration::{BuildOptions, Concurrency, Constraints, IndexStrategy, SourceStrategy};
|
||||
use uv_configuration::{BuildOptions, Concurrency, Constraints, IndexStrategy, NoSources};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
use uv_distribution::DistributionDatabase;
|
||||
use uv_distribution_types::{
|
||||
@@ -168,7 +168,7 @@ mod resolver {
|
||||
let options = OptionsBuilder::new()
|
||||
.exclude_newer(exclude_newer.clone())
|
||||
.build();
|
||||
let sources = SourceStrategy::default();
|
||||
let sources = NoSources::default();
|
||||
let dependency_metadata = DependencyMetadata::default();
|
||||
let conflicts = Conflicts::empty();
|
||||
let workspace_cache = WorkspaceCache::default();
|
||||
|
||||
@@ -30,7 +30,7 @@ use tokio::sync::{Mutex, Semaphore};
|
||||
use tracing::{Instrument, debug, info_span, instrument, warn};
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_cache_key::cache_digest;
|
||||
use uv_configuration::{BuildKind, BuildOutput, SourceStrategy};
|
||||
use uv_configuration::{BuildKind, BuildOutput, NoSources};
|
||||
use uv_distribution::BuildRequires;
|
||||
use uv_distribution_types::{
|
||||
ConfigSettings, ExtraBuildRequirement, ExtraBuildRequires, IndexLocations, Requirement,
|
||||
@@ -282,7 +282,7 @@ impl SourceBuild {
|
||||
source_build_context: SourceBuildContext,
|
||||
version_id: Option<&str>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: NoSources,
|
||||
workspace_cache: &WorkspaceCache,
|
||||
config_settings: ConfigSettings,
|
||||
build_isolation: BuildIsolation<'_>,
|
||||
@@ -309,7 +309,7 @@ impl SourceBuild {
|
||||
install_path,
|
||||
fallback_package_name,
|
||||
locations,
|
||||
source_strategy,
|
||||
&no_sources,
|
||||
workspace_cache,
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -445,7 +445,7 @@ impl SourceBuild {
|
||||
package_version.as_ref(),
|
||||
version_id,
|
||||
locations,
|
||||
source_strategy,
|
||||
no_sources,
|
||||
workspace_cache,
|
||||
build_stack,
|
||||
build_kind,
|
||||
@@ -561,7 +561,7 @@ impl SourceBuild {
|
||||
install_path: &Path,
|
||||
package_name: Option<&PackageName>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: &NoSources,
|
||||
workspace_cache: &WorkspaceCache,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<(Pep517Backend, Option<Project>), Box<Error>> {
|
||||
@@ -574,42 +574,35 @@ impl SourceBuild {
|
||||
|
||||
let backend = if let Some(build_system) = pyproject_toml.build_system {
|
||||
// If necessary, lower the requirements.
|
||||
let requirements = match source_strategy {
|
||||
SourceStrategy::Enabled => {
|
||||
if let Some(name) = pyproject_toml
|
||||
.project
|
||||
.as_ref()
|
||||
.map(|project| &project.name)
|
||||
.or(package_name)
|
||||
{
|
||||
let build_requires = uv_pypi_types::BuildRequires {
|
||||
name: Some(name.clone()),
|
||||
requires_dist: build_system.requires,
|
||||
};
|
||||
let build_requires = BuildRequires::from_project_maybe_workspace(
|
||||
build_requires,
|
||||
install_path,
|
||||
locations,
|
||||
source_strategy,
|
||||
workspace_cache,
|
||||
credentials_cache,
|
||||
)
|
||||
.await
|
||||
.map_err(Error::Lowering)?;
|
||||
build_requires.requires_dist
|
||||
} else {
|
||||
build_system
|
||||
.requires
|
||||
.into_iter()
|
||||
.map(Requirement::from)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
SourceStrategy::Disabled => build_system
|
||||
let requirements = if let Some(name) = pyproject_toml
|
||||
.project
|
||||
.as_ref()
|
||||
.map(|project| &project.name)
|
||||
.or(package_name)
|
||||
// If sources are disabled, there's nothing to do here
|
||||
.filter(|_| !no_sources.all())
|
||||
{
|
||||
let build_requires = uv_pypi_types::BuildRequires {
|
||||
name: Some(name.clone()),
|
||||
requires_dist: build_system.requires,
|
||||
};
|
||||
let build_requires = BuildRequires::from_project_maybe_workspace(
|
||||
build_requires,
|
||||
install_path,
|
||||
locations,
|
||||
no_sources,
|
||||
workspace_cache,
|
||||
credentials_cache,
|
||||
)
|
||||
.await
|
||||
.map_err(Error::Lowering)?;
|
||||
build_requires.requires_dist
|
||||
} else {
|
||||
build_system
|
||||
.requires
|
||||
.into_iter()
|
||||
.map(Requirement::from)
|
||||
.collect(),
|
||||
.collect()
|
||||
};
|
||||
|
||||
Pep517Backend {
|
||||
@@ -956,7 +949,7 @@ async fn create_pep517_build_environment(
|
||||
package_version: Option<&Version>,
|
||||
version_id: Option<&str>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: NoSources,
|
||||
workspace_cache: &WorkspaceCache,
|
||||
build_stack: &BuildStack,
|
||||
build_kind: BuildKind,
|
||||
@@ -1048,25 +1041,24 @@ async fn create_pep517_build_environment(
|
||||
};
|
||||
|
||||
// If necessary, lower the requirements.
|
||||
let extra_requires = match source_strategy {
|
||||
SourceStrategy::Enabled => {
|
||||
let build_requires = uv_pypi_types::BuildRequires {
|
||||
name: package_name.cloned(),
|
||||
requires_dist: extra_requires,
|
||||
};
|
||||
let build_requires = BuildRequires::from_project_maybe_workspace(
|
||||
build_requires,
|
||||
install_path,
|
||||
locations,
|
||||
source_strategy,
|
||||
workspace_cache,
|
||||
credentials_cache,
|
||||
)
|
||||
.await
|
||||
.map_err(Error::Lowering)?;
|
||||
build_requires.requires_dist
|
||||
}
|
||||
SourceStrategy::Disabled => extra_requires.into_iter().map(Requirement::from).collect(),
|
||||
let extra_requires = if no_sources.all() {
|
||||
extra_requires.into_iter().map(Requirement::from).collect()
|
||||
} else {
|
||||
let build_requires = uv_pypi_types::BuildRequires {
|
||||
name: package_name.cloned(),
|
||||
requires_dist: extra_requires,
|
||||
};
|
||||
let build_requires = BuildRequires::from_project_maybe_workspace(
|
||||
build_requires,
|
||||
install_path,
|
||||
locations,
|
||||
&no_sources,
|
||||
workspace_cache,
|
||||
credentials_cache,
|
||||
)
|
||||
.await
|
||||
.map_err(Error::Lowering)?;
|
||||
build_requires.requires_dist
|
||||
};
|
||||
|
||||
// Some packages (such as tqdm 4.66.1) list only extra requires that have already been part of
|
||||
|
||||
@@ -5933,6 +5933,10 @@ pub struct ToolUpgradeArgs {
|
||||
)]
|
||||
pub no_sources: bool,
|
||||
|
||||
/// Don't use sources from the `tool.uv.sources` table for the specified packages.
|
||||
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
|
||||
pub no_sources_package: Vec<PackageName>,
|
||||
|
||||
#[command(flatten)]
|
||||
pub build: BuildOptionsArgs,
|
||||
}
|
||||
@@ -6950,6 +6954,10 @@ pub struct InstallerArgs {
|
||||
help_heading = "Resolver options"
|
||||
)]
|
||||
pub no_sources: bool,
|
||||
|
||||
/// Don't use sources from the `tool.uv.sources` table for the specified packages.
|
||||
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
|
||||
pub no_sources_package: Vec<PackageName>,
|
||||
}
|
||||
|
||||
/// Arguments that are used by commands that need to resolve (but not install) packages.
|
||||
@@ -7157,6 +7165,10 @@ pub struct ResolverArgs {
|
||||
help_heading = "Resolver options",
|
||||
)]
|
||||
pub no_sources: bool,
|
||||
|
||||
/// Don't use sources from the `tool.uv.sources` table for the specified packages.
|
||||
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
|
||||
pub no_sources_package: Vec<PackageName>,
|
||||
}
|
||||
|
||||
/// Arguments that are used by commands that need to resolve and install packages.
|
||||
@@ -7421,6 +7433,10 @@ pub struct ResolverInstallerArgs {
|
||||
help_heading = "Resolver options",
|
||||
)]
|
||||
pub no_sources: bool,
|
||||
|
||||
/// Don't use sources from the `tool.uv.sources` table for the specified packages.
|
||||
#[arg(long, help_heading = "Resolver options", env = EnvVars::UV_NO_SOURCES_PACKAGE, value_delimiter = ' ')]
|
||||
pub no_sources_package: Vec<PackageName>,
|
||||
}
|
||||
|
||||
/// Arguments that are used by commands that need to fetch from the Simple API.
|
||||
|
||||
@@ -216,6 +216,7 @@ impl From<ResolverArgs> for PipOptions {
|
||||
exclude_newer,
|
||||
link_mode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
exclude_newer_package,
|
||||
} = args;
|
||||
|
||||
@@ -244,6 +245,7 @@ impl From<ResolverArgs> for PipOptions {
|
||||
exclude_newer_package: exclude_newer_package.map(ExcludeNewerPackage::from_iter),
|
||||
link_mode,
|
||||
no_sources: if no_sources { Some(true) } else { None },
|
||||
no_sources_package: Some(no_sources_package),
|
||||
..Self::from(index_args)
|
||||
}
|
||||
}
|
||||
@@ -267,6 +269,7 @@ impl From<InstallerArgs> for PipOptions {
|
||||
compile_bytecode,
|
||||
no_compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
exclude_newer_package,
|
||||
} = args;
|
||||
|
||||
@@ -288,6 +291,7 @@ impl From<InstallerArgs> for PipOptions {
|
||||
link_mode,
|
||||
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
||||
no_sources: if no_sources { Some(true) } else { None },
|
||||
no_sources_package: Some(no_sources_package),
|
||||
..Self::from(index_args)
|
||||
}
|
||||
}
|
||||
@@ -319,6 +323,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
|
||||
compile_bytecode,
|
||||
no_compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
exclude_newer_package,
|
||||
} = args;
|
||||
|
||||
@@ -350,6 +355,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
|
||||
link_mode,
|
||||
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
||||
no_sources: if no_sources { Some(true) } else { None },
|
||||
no_sources_package: Some(no_sources_package),
|
||||
..Self::from(index_args)
|
||||
}
|
||||
}
|
||||
@@ -438,6 +444,7 @@ pub fn resolver_options(
|
||||
exclude_newer,
|
||||
link_mode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
exclude_newer_package,
|
||||
} = resolver_args;
|
||||
|
||||
@@ -518,6 +525,7 @@ pub fn resolver_options(
|
||||
no_binary: flag(no_binary, binary, "binary"),
|
||||
no_binary_package: Some(no_binary_package),
|
||||
no_sources: if no_sources { Some(true) } else { None },
|
||||
no_sources_package: Some(no_sources_package),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,6 +559,7 @@ pub fn resolver_installer_options(
|
||||
compile_bytecode,
|
||||
no_compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
} = resolver_installer_args;
|
||||
|
||||
let BuildOptionsArgs {
|
||||
@@ -642,6 +651,11 @@ pub fn resolver_installer_options(
|
||||
Some(no_binary_package)
|
||||
},
|
||||
no_sources: if no_sources { Some(true) } else { None },
|
||||
no_sources_package: if no_sources_package.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(no_sources_package)
|
||||
},
|
||||
torch_backend: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,83 @@
|
||||
#[derive(
|
||||
Debug, Default, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize,
|
||||
)]
|
||||
use uv_normalize::PackageName;
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
|
||||
pub enum SourceStrategy {
|
||||
pub enum NoSources {
|
||||
/// Use `tool.uv.sources` when resolving dependencies.
|
||||
#[default]
|
||||
Enabled,
|
||||
/// Ignore `tool.uv.sources` when resolving dependencies.
|
||||
Disabled,
|
||||
None,
|
||||
|
||||
/// Ignore `tool.uv.sources` when resolving dependencies for all packages.
|
||||
All,
|
||||
|
||||
/// Ignore `tool.uv.sources` when resolving dependencies for specific packages.
|
||||
Packages(Vec<PackageName>),
|
||||
}
|
||||
|
||||
impl SourceStrategy {
|
||||
/// Return the [`SourceStrategy`] from the command-line arguments, if any.
|
||||
pub fn from_args(no_sources: bool) -> Self {
|
||||
if no_sources {
|
||||
Self::Disabled
|
||||
} else {
|
||||
Self::Enabled
|
||||
impl NoSources {
|
||||
/// Determine the no sources strategy to use for the given arguments.
|
||||
pub fn from_args(no_sources: Option<bool>, no_sources_package: Vec<PackageName>) -> Self {
|
||||
match no_sources {
|
||||
Some(true) => Self::All,
|
||||
Some(false) => Self::None,
|
||||
None => {
|
||||
if no_sources_package.is_empty() {
|
||||
Self::None
|
||||
} else {
|
||||
Self::Packages(no_sources_package)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if all sources should be ignored.
|
||||
pub fn all(&self) -> bool {
|
||||
matches!(self, Self::All)
|
||||
}
|
||||
|
||||
/// Returns `true` if sources should be ignored for the given package.
|
||||
pub fn for_package(&self, package_name: &PackageName) -> bool {
|
||||
match self {
|
||||
Self::None => false,
|
||||
Self::All => true,
|
||||
Self::Packages(packages) => packages.contains(package_name),
|
||||
}
|
||||
}
|
||||
|
||||
/// Combine a set of [`NoSources`] values.
|
||||
#[must_use]
|
||||
pub fn combine(self, other: Self) -> Self {
|
||||
match (self, other) {
|
||||
(Self::None, Self::None) => Self::None,
|
||||
(Self::All, _) | (_, Self::All) => Self::All,
|
||||
(Self::Packages(a), Self::None) => Self::Packages(a),
|
||||
(Self::None, Self::Packages(b)) => Self::Packages(b),
|
||||
(Self::Packages(mut a), Self::Packages(b)) => {
|
||||
a.extend(b);
|
||||
Self::Packages(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extend a [`NoSources`] value with another.
|
||||
pub fn extend(&mut self, other: Self) {
|
||||
match (&mut *self, other) {
|
||||
(Self::All, _) | (_, Self::All) => *self = Self::All,
|
||||
(Self::None, Self::None) => {}
|
||||
(Self::Packages(_), Self::None) => {}
|
||||
(Self::None, Self::Packages(b)) => {
|
||||
*self = Self::Packages(b);
|
||||
}
|
||||
(Self::Packages(a), Self::Packages(b)) => {
|
||||
a.extend(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NoSources {
|
||||
/// Returns `true` if all sources are allowed.
|
||||
pub fn is_none(&self) -> bool {
|
||||
matches!(self, Self::None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,7 @@ use uv_build_backend::check_direct_build;
|
||||
use uv_build_frontend::{SourceBuild, SourceBuildContext};
|
||||
use uv_cache::Cache;
|
||||
use uv_client::RegistryClient;
|
||||
use uv_configuration::{
|
||||
BuildKind, BuildOptions, Constraints, IndexStrategy, Reinstall, SourceStrategy,
|
||||
};
|
||||
use uv_configuration::{BuildKind, BuildOptions, Constraints, IndexStrategy, NoSources, Reinstall};
|
||||
use uv_configuration::{BuildOutput, Concurrency};
|
||||
use uv_distribution::DistributionDatabase;
|
||||
use uv_distribution_filename::DistFilename;
|
||||
@@ -99,7 +97,7 @@ pub struct BuildDispatch<'a> {
|
||||
exclude_newer: ExcludeNewer,
|
||||
source_build_context: SourceBuildContext,
|
||||
build_extra_env_vars: FxHashMap<OsString, OsString>,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
workspace_cache: WorkspaceCache,
|
||||
concurrency: Concurrency,
|
||||
preview: Preview,
|
||||
@@ -125,7 +123,7 @@ impl<'a> BuildDispatch<'a> {
|
||||
build_options: &'a BuildOptions,
|
||||
hasher: &'a HashStrategy,
|
||||
exclude_newer: ExcludeNewer,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
workspace_cache: WorkspaceCache,
|
||||
concurrency: Concurrency,
|
||||
preview: Preview,
|
||||
@@ -218,8 +216,8 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
self.config_settings_package
|
||||
}
|
||||
|
||||
fn sources(&self) -> SourceStrategy {
|
||||
self.sources
|
||||
fn sources(&self) -> &NoSources {
|
||||
&self.sources
|
||||
}
|
||||
|
||||
fn locations(&self) -> &IndexLocations {
|
||||
@@ -414,7 +412,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
install_path: &'data Path,
|
||||
version_id: Option<&'data str>,
|
||||
dist: Option<&'data SourceDist>,
|
||||
sources: SourceStrategy,
|
||||
sources: &'data NoSources,
|
||||
build_kind: BuildKind,
|
||||
build_output: BuildOutput,
|
||||
mut build_stack: BuildStack,
|
||||
@@ -482,7 +480,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
self.source_build_context.clone(),
|
||||
version_id,
|
||||
self.index_locations,
|
||||
sources,
|
||||
sources.clone(),
|
||||
self.workspace_cache(),
|
||||
config_settings,
|
||||
self.build_isolation,
|
||||
@@ -505,7 +503,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
source: &'data Path,
|
||||
subdirectory: Option<&'data Path>,
|
||||
output_dir: &'data Path,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
build_kind: BuildKind,
|
||||
version_id: Option<&'data str>,
|
||||
) -> Result<Option<DistFilename>, BuildDispatchError> {
|
||||
@@ -535,7 +533,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
&output_dir,
|
||||
None,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources.is_none(),
|
||||
preview,
|
||||
)?;
|
||||
DistFilename::WheelFilename(wheel)
|
||||
@@ -545,7 +543,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
&source_tree,
|
||||
&output_dir,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources.is_none(),
|
||||
)?;
|
||||
DistFilename::SourceDistFilename(source_dist)
|
||||
}
|
||||
@@ -555,7 +553,7 @@ impl BuildContext for BuildDispatch<'_> {
|
||||
&output_dir,
|
||||
None,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources.is_none(),
|
||||
preview,
|
||||
)?;
|
||||
DistFilename::WheelFilename(wheel)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_distribution_types::{
|
||||
ExtraBuildRequirement, ExtraBuildRequires, IndexLocations, Requirement,
|
||||
};
|
||||
@@ -40,16 +41,17 @@ impl BuildRequires {
|
||||
metadata: uv_pypi_types::BuildRequires,
|
||||
install_path: &Path,
|
||||
locations: &IndexLocations,
|
||||
sources: SourceStrategy,
|
||||
sources: &NoSources,
|
||||
cache: &WorkspaceCache,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
let discovery = match sources {
|
||||
SourceStrategy::Enabled => DiscoveryOptions::default(),
|
||||
SourceStrategy::Disabled => DiscoveryOptions {
|
||||
let discovery = if sources.all() {
|
||||
DiscoveryOptions {
|
||||
members: MemberDiscovery::None,
|
||||
..Default::default()
|
||||
},
|
||||
}
|
||||
} else {
|
||||
DiscoveryOptions::default()
|
||||
};
|
||||
let Some(project_workspace) =
|
||||
ProjectWorkspace::from_maybe_project_root(install_path, &discovery, cache).await?
|
||||
@@ -71,27 +73,30 @@ impl BuildRequires {
|
||||
metadata: uv_pypi_types::BuildRequires,
|
||||
project_workspace: &ProjectWorkspace,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
sources: &NoSources,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
// Collect any `tool.uv.index` entries.
|
||||
let empty = vec![];
|
||||
let project_indexes = match source_strategy {
|
||||
SourceStrategy::Enabled => project_workspace
|
||||
let project_indexes = if sources.all() {
|
||||
&empty
|
||||
} else {
|
||||
project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.index.as_deref())
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
.unwrap_or(&empty)
|
||||
};
|
||||
|
||||
// Collect any `tool.uv.sources` and `tool.uv.dev_dependencies` from `pyproject.toml`.
|
||||
let empty = BTreeMap::default();
|
||||
let project_sources = match source_strategy {
|
||||
SourceStrategy::Enabled => project_workspace
|
||||
let project_sources = if sources.all() {
|
||||
&empty
|
||||
} else {
|
||||
project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
@@ -99,41 +104,48 @@ impl BuildRequires {
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.map(ToolUvSources::inner)
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
.unwrap_or(&empty)
|
||||
};
|
||||
|
||||
// Lower the requirements.
|
||||
let requires_dist = metadata.requires_dist.into_iter();
|
||||
let requires_dist = match source_strategy {
|
||||
SourceStrategy::Enabled => requires_dist
|
||||
let requires_dist = if sources.all() {
|
||||
requires_dist.into_iter().map(Requirement::from).collect()
|
||||
} else {
|
||||
requires_dist
|
||||
.flat_map(|requirement| {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let extra = requirement.marker.top_level_extra_name();
|
||||
let group = None;
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
metadata.name.as_ref(),
|
||||
project_workspace.project_root(),
|
||||
project_sources,
|
||||
project_indexes,
|
||||
extra.as_deref(),
|
||||
group,
|
||||
locations,
|
||||
project_workspace.workspace(),
|
||||
None,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::LoweringError(
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
// Check if sources should be disabled for this specific package
|
||||
if sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let extra = requirement.marker.top_level_extra_name();
|
||||
let group = None;
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
metadata.name.as_ref(),
|
||||
project_workspace.project_root(),
|
||||
project_sources,
|
||||
project_indexes,
|
||||
extra.as_deref(),
|
||||
group,
|
||||
locations,
|
||||
project_workspace.workspace(),
|
||||
None,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::LoweringError(
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
SourceStrategy::Disabled => requires_dist.into_iter().map(Requirement::from).collect(),
|
||||
.collect::<Result<Vec<_>, _>>()?
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
@@ -147,44 +159,42 @@ impl BuildRequires {
|
||||
metadata: uv_pypi_types::BuildRequires,
|
||||
workspace: &Workspace,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
sources: &NoSources,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
// Collect any `tool.uv.index` entries.
|
||||
let empty = vec![];
|
||||
let project_indexes = match source_strategy {
|
||||
SourceStrategy::Enabled => workspace
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.index.as_deref())
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
};
|
||||
let project_indexes = workspace
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.index.as_deref())
|
||||
.unwrap_or(&empty);
|
||||
|
||||
// Collect any `tool.uv.sources` and `tool.uv.dev_dependencies` from `pyproject.toml`.
|
||||
let empty = BTreeMap::default();
|
||||
let project_sources = match source_strategy {
|
||||
SourceStrategy::Enabled => workspace
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.map(ToolUvSources::inner)
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
};
|
||||
let project_sources = workspace
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.map(ToolUvSources::inner)
|
||||
.unwrap_or(&empty);
|
||||
|
||||
// Lower the requirements.
|
||||
let requires_dist = metadata.requires_dist.into_iter();
|
||||
let requires_dist = match source_strategy {
|
||||
SourceStrategy::Enabled => requires_dist
|
||||
.flat_map(|requirement| {
|
||||
let requires_dist = requires_dist
|
||||
.flat_map(|requirement| {
|
||||
// Check if sources should be disabled for this specific package
|
||||
if sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let extra = requirement.marker.top_level_extra_name();
|
||||
let group = None;
|
||||
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
None,
|
||||
@@ -205,10 +215,11 @@ impl BuildRequires {
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
SourceStrategy::Disabled => requires_dist.into_iter().map(Requirement::from).collect(),
|
||||
};
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(Self {
|
||||
name: metadata.name,
|
||||
@@ -235,11 +246,11 @@ impl LoweredExtraBuildDependencies {
|
||||
extra_build_dependencies: ExtraBuildDependencies,
|
||||
workspace: &Workspace,
|
||||
index_locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
source_strategy: &NoSources,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
match source_strategy {
|
||||
SourceStrategy::Enabled => {
|
||||
NoSources::None => {
|
||||
// Collect project sources and indexes
|
||||
let project_indexes = workspace
|
||||
.pyproject_toml()
|
||||
@@ -304,7 +315,10 @@ impl LoweredExtraBuildDependencies {
|
||||
}
|
||||
Ok(Self(build_requires))
|
||||
}
|
||||
SourceStrategy::Disabled => Ok(Self::from_non_lowered(extra_build_dependencies)),
|
||||
NoSources::All | NoSources::Packages(_) => {
|
||||
// Without source resolution, just return the dependencies as-is
|
||||
Ok(Self::from_non_lowered(extra_build_dependencies))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_distribution_types::{IndexLocations, Requirement};
|
||||
use uv_normalize::{GroupName, PackageName};
|
||||
use uv_workspace::dependency_groups::FlatDependencyGroups;
|
||||
@@ -55,7 +56,7 @@ impl SourcedDependencyGroups {
|
||||
pyproject_path: &Path,
|
||||
git_member: Option<&GitWorkspaceMember<'_>>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: NoSources,
|
||||
cache: &WorkspaceCache,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
@@ -74,9 +75,10 @@ impl SourcedDependencyGroups {
|
||||
.expect("git checkout has a parent")
|
||||
.to_path_buf()
|
||||
}),
|
||||
members: match source_strategy {
|
||||
SourceStrategy::Enabled => MemberDiscovery::default(),
|
||||
SourceStrategy::Disabled => MemberDiscovery::None,
|
||||
members: if no_sources.is_none() {
|
||||
MemberDiscovery::default()
|
||||
} else {
|
||||
MemberDiscovery::None
|
||||
},
|
||||
..DiscoveryOptions::default()
|
||||
};
|
||||
@@ -92,8 +94,8 @@ impl SourcedDependencyGroups {
|
||||
let dependency_groups =
|
||||
FlatDependencyGroups::from_pyproject_toml(project.root(), project.pyproject_toml())?;
|
||||
|
||||
// If sources/indexes are disabled we can just stop here
|
||||
let SourceStrategy::Enabled = source_strategy else {
|
||||
// Early return if all sources are disabled
|
||||
if matches!(no_sources, NoSources::All) {
|
||||
return Ok(Self {
|
||||
name: project.project_name().cloned(),
|
||||
dependency_groups: dependency_groups
|
||||
@@ -108,7 +110,7 @@ impl SourcedDependencyGroups {
|
||||
})
|
||||
.collect(),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Collect any `tool.uv.index` entries.
|
||||
let empty = vec![];
|
||||
@@ -143,30 +145,38 @@ impl SourcedDependencyGroups {
|
||||
.requirements
|
||||
.into_iter()
|
||||
.flat_map(|requirement| {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let group = name.clone();
|
||||
let extra = None;
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
project.project_name(),
|
||||
project.root(),
|
||||
project_sources,
|
||||
project_indexes,
|
||||
extra,
|
||||
Some(&group),
|
||||
locations,
|
||||
project.workspace(),
|
||||
git_member,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::GroupLoweringError(
|
||||
group.clone(),
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
// Check if sources should be disabled for this specific package
|
||||
if no_sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let group = name.clone();
|
||||
let extra = None;
|
||||
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
project.project_name(),
|
||||
project.root(),
|
||||
project_sources,
|
||||
project_indexes,
|
||||
extra,
|
||||
Some(&group),
|
||||
locations,
|
||||
project.workspace(),
|
||||
git_member,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::GroupLoweringError(
|
||||
group.clone(),
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<Box<_>, _>>()?;
|
||||
Ok::<(GroupName, Box<_>), MetadataError>((name, requirements))
|
||||
|
||||
@@ -2,8 +2,9 @@ use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_distribution_types::{GitSourceUrl, IndexLocations, Requirement};
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_pep440::{Version, VersionSpecifiers};
|
||||
@@ -89,7 +90,7 @@ impl Metadata {
|
||||
install_path: &Path,
|
||||
git_source: Option<&GitWorkspaceMember<'_>>,
|
||||
locations: &IndexLocations,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
cache: &WorkspaceCache,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
|
||||
@@ -3,8 +3,9 @@ use std::path::Path;
|
||||
use std::slice;
|
||||
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_distribution_types::{IndexLocations, Requirement};
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_pep508::MarkerTree;
|
||||
@@ -46,7 +47,7 @@ impl RequiresDist {
|
||||
install_path: &Path,
|
||||
git_member: Option<&GitWorkspaceMember<'_>>,
|
||||
locations: &IndexLocations,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
cache: &WorkspaceCache,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
@@ -58,9 +59,10 @@ impl RequiresDist {
|
||||
.expect("git checkout has a parent")
|
||||
.to_path_buf()
|
||||
}),
|
||||
members: match sources {
|
||||
SourceStrategy::Enabled => MemberDiscovery::default(),
|
||||
SourceStrategy::Disabled => MemberDiscovery::None,
|
||||
members: if sources.is_none() {
|
||||
MemberDiscovery::default()
|
||||
} else {
|
||||
MemberDiscovery::None
|
||||
},
|
||||
..DiscoveryOptions::default()
|
||||
};
|
||||
@@ -75,7 +77,7 @@ impl RequiresDist {
|
||||
&project_workspace,
|
||||
git_member,
|
||||
locations,
|
||||
sources,
|
||||
&sources,
|
||||
credentials_cache,
|
||||
)
|
||||
}
|
||||
@@ -85,37 +87,31 @@ impl RequiresDist {
|
||||
project_workspace: &ProjectWorkspace,
|
||||
git_member: Option<&GitWorkspaceMember<'_>>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: &NoSources,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Self, MetadataError> {
|
||||
// Collect any `tool.uv.index` entries.
|
||||
let empty = vec![];
|
||||
let project_indexes = match source_strategy {
|
||||
SourceStrategy::Enabled => project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.index.as_deref())
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
};
|
||||
let project_indexes = project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.index.as_deref())
|
||||
.unwrap_or(&empty);
|
||||
|
||||
// Collect any `tool.uv.sources` and `tool.uv.dev_dependencies` from `pyproject.toml`.
|
||||
let empty = BTreeMap::default();
|
||||
let project_sources = match source_strategy {
|
||||
SourceStrategy::Enabled => project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.map(ToolUvSources::inner)
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
};
|
||||
let project_sources = project_workspace
|
||||
.current_project()
|
||||
.pyproject_toml()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.map(ToolUvSources::inner)
|
||||
.unwrap_or(&empty);
|
||||
|
||||
let dependency_groups = FlatDependencyGroups::from_pyproject_toml(
|
||||
project_workspace.current_project().root(),
|
||||
@@ -130,14 +126,18 @@ impl RequiresDist {
|
||||
let dependency_groups = dependency_groups
|
||||
.into_iter()
|
||||
.map(|(name, flat_group)| {
|
||||
let requirements = match source_strategy {
|
||||
SourceStrategy::Enabled => flat_group
|
||||
.requirements
|
||||
.into_iter()
|
||||
.flat_map(|requirement| {
|
||||
let requirements = flat_group
|
||||
.requirements
|
||||
.into_iter()
|
||||
.flat_map(|requirement| {
|
||||
// Check if sources should be disabled for this specific package
|
||||
if no_sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let group = name.clone();
|
||||
let extra = None;
|
||||
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
Some(&metadata.name),
|
||||
@@ -151,36 +151,35 @@ impl RequiresDist {
|
||||
git_member,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(
|
||||
move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::GroupLoweringError(
|
||||
group.clone(),
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect::<Result<Box<_>, _>>(),
|
||||
SourceStrategy::Disabled => Ok(flat_group
|
||||
.requirements
|
||||
.into_iter()
|
||||
.map(Requirement::from)
|
||||
.collect()),
|
||||
}?;
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(MetadataError::GroupLoweringError(
|
||||
group.clone(),
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<Box<_>, _>>()?;
|
||||
Ok::<(GroupName, Box<_>), MetadataError>((name, requirements))
|
||||
})
|
||||
.collect::<Result<BTreeMap<_, _>, _>>()?;
|
||||
|
||||
// Lower the requirements.
|
||||
let requires_dist = Box::into_iter(metadata.requires_dist);
|
||||
let requires_dist = match source_strategy {
|
||||
SourceStrategy::Enabled => requires_dist
|
||||
.flat_map(|requirement| {
|
||||
let requires_dist = requires_dist
|
||||
.flat_map(|requirement| {
|
||||
// Check if sources should be disabled for this specific package
|
||||
if no_sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
let extra = requirement.marker.top_level_extra_name();
|
||||
let group = None;
|
||||
|
||||
LoweredRequirement::from_requirement(
|
||||
requirement,
|
||||
Some(&metadata.name),
|
||||
@@ -201,10 +200,11 @@ impl RequiresDist {
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
})
|
||||
.collect::<Result<Box<_>, _>>()?,
|
||||
SourceStrategy::Disabled => requires_dist.into_iter().map(Requirement::from).collect(),
|
||||
};
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<Box<_>, _>>()?;
|
||||
|
||||
Ok(Self {
|
||||
name: metadata.name,
|
||||
@@ -443,8 +443,9 @@ mod test {
|
||||
use anyhow::Context;
|
||||
use indoc::indoc;
|
||||
use insta::assert_snapshot;
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_distribution_types::IndexLocations;
|
||||
use uv_normalize::PackageName;
|
||||
use uv_pep508::Requirement;
|
||||
@@ -478,7 +479,7 @@ mod test {
|
||||
&project_workspace,
|
||||
None,
|
||||
&IndexLocations::default(),
|
||||
SourceStrategy::default(),
|
||||
&NoSources::default(),
|
||||
&CredentialsCache::new(),
|
||||
)?)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ use uv_cache_info::CacheInfo;
|
||||
use uv_client::{
|
||||
CacheControl, CachedClientError, Connectivity, DataWithCachePolicy, RegistryClient,
|
||||
};
|
||||
use uv_configuration::{BuildKind, BuildOutput, SourceStrategy};
|
||||
use uv_configuration::{BuildKind, BuildOutput, NoSources};
|
||||
use uv_distribution_filename::{SourceDistExtension, WheelFilename};
|
||||
use uv_distribution_types::{
|
||||
BuildInfo, BuildVariables, BuildableSource, ConfigSettings, DirectorySourceUrl,
|
||||
@@ -546,7 +546,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_dist_entry.path(),
|
||||
subdirectory,
|
||||
&cache_shard,
|
||||
SourceStrategy::Disabled,
|
||||
NoSources::None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -674,7 +674,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source,
|
||||
source_dist_entry.path(),
|
||||
subdirectory,
|
||||
SourceStrategy::Disabled,
|
||||
NoSources::None,
|
||||
)
|
||||
.boxed_local()
|
||||
.await?
|
||||
@@ -726,7 +726,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_dist_entry.path(),
|
||||
subdirectory,
|
||||
&cache_shard,
|
||||
SourceStrategy::Disabled,
|
||||
NoSources::None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -927,7 +927,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_entry.path(),
|
||||
None,
|
||||
&cache_shard,
|
||||
SourceStrategy::Disabled,
|
||||
NoSources::None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1026,7 +1026,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
|
||||
// If the backend supports `prepare_metadata_for_build_wheel`, use it.
|
||||
if let Some(metadata) = self
|
||||
.build_metadata(source, source_entry.path(), None, SourceStrategy::Disabled)
|
||||
.build_metadata(source, source_entry.path(), None, NoSources::None)
|
||||
.boxed_local()
|
||||
.await?
|
||||
{
|
||||
@@ -1077,7 +1077,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_entry.path(),
|
||||
None,
|
||||
&cache_shard,
|
||||
SourceStrategy::Disabled,
|
||||
NoSources::None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1236,7 +1236,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
&resource.install_path,
|
||||
None,
|
||||
&cache_shard,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1288,7 +1288,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
resource.install_path.as_ref(),
|
||||
None,
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1342,7 +1342,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
resource.install_path.as_ref(),
|
||||
None,
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1363,7 +1363,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source,
|
||||
&resource.install_path,
|
||||
None,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.boxed_local()
|
||||
.await?
|
||||
@@ -1392,7 +1392,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
resource.install_path.as_ref(),
|
||||
None,
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1423,7 +1423,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
&resource.install_path,
|
||||
None,
|
||||
&cache_shard,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1454,7 +1454,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
resource.install_path.as_ref(),
|
||||
None,
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1530,7 +1530,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
path,
|
||||
None,
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1657,7 +1657,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
fetch.path(),
|
||||
resource.subdirectory,
|
||||
&cache_shard,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1852,7 +1852,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
&path,
|
||||
Some(&git_member),
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1886,7 +1886,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
&path,
|
||||
Some(&git_member),
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1910,7 +1910,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source,
|
||||
fetch.path(),
|
||||
resource.subdirectory,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.boxed_local()
|
||||
.await?
|
||||
@@ -1939,7 +1939,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
&path,
|
||||
Some(&git_member),
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -1970,7 +1970,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
fetch.path(),
|
||||
resource.subdirectory,
|
||||
&cache_shard,
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -2001,7 +2001,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
fetch.path(),
|
||||
Some(&git_member),
|
||||
self.build_context.locations(),
|
||||
self.build_context.sources(),
|
||||
self.build_context.sources().clone(),
|
||||
self.build_context.workspace_cache(),
|
||||
credentials_cache,
|
||||
)
|
||||
@@ -2434,7 +2434,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root: &Path,
|
||||
subdirectory: Option<&Path>,
|
||||
cache_shard: &CacheShard,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: NoSources,
|
||||
) -> Result<(String, WheelFilename, ResolutionMetadata), Error> {
|
||||
debug!("Building: {source}");
|
||||
|
||||
@@ -2470,7 +2470,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root,
|
||||
subdirectory,
|
||||
temp_dir.path(),
|
||||
source_strategy,
|
||||
no_sources.clone(),
|
||||
if source.is_editable() {
|
||||
BuildKind::Editable
|
||||
} else {
|
||||
@@ -2510,7 +2510,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root: source_root.to_path_buf().into_boxed_path(),
|
||||
subdirectory: subdirectory
|
||||
.map(|subdirectory| subdirectory.to_path_buf().into_boxed_path()),
|
||||
source_strategy,
|
||||
no_sources: no_sources.clone(),
|
||||
build_kind,
|
||||
};
|
||||
|
||||
@@ -2533,7 +2533,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root,
|
||||
Some(&source.to_string()),
|
||||
source.as_dist(),
|
||||
source_strategy,
|
||||
&no_sources,
|
||||
if source.is_editable() {
|
||||
BuildKind::Editable
|
||||
} else {
|
||||
@@ -2586,7 +2586,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source: &BuildableSource<'_>,
|
||||
source_root: &Path,
|
||||
subdirectory: Option<&Path>,
|
||||
source_strategy: SourceStrategy,
|
||||
no_sources: NoSources,
|
||||
) -> Result<Option<ResolutionMetadata>, Error> {
|
||||
debug!("Preparing metadata for: {source}");
|
||||
|
||||
@@ -2642,7 +2642,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root,
|
||||
Some(&source.to_string()),
|
||||
source.as_dist(),
|
||||
source_strategy,
|
||||
&no_sources,
|
||||
build_kind,
|
||||
if uv_flags::contains(uv_flags::EnvironmentFlags::HIDE_BUILD_OUTPUT) {
|
||||
BuildOutput::Quiet
|
||||
@@ -2664,7 +2664,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
||||
source_root: source_root.to_path_buf().into_boxed_path(),
|
||||
subdirectory: subdirectory
|
||||
.map(|subdirectory| subdirectory.to_path_buf().into_boxed_path()),
|
||||
source_strategy,
|
||||
no_sources,
|
||||
build_kind,
|
||||
},
|
||||
builder,
|
||||
|
||||
@@ -9,7 +9,7 @@ use serde::Deserialize;
|
||||
use thiserror::Error;
|
||||
use url::Url;
|
||||
|
||||
use uv_configuration::SourceStrategy;
|
||||
use uv_configuration::NoSources;
|
||||
use uv_normalize::PackageName;
|
||||
use uv_pep440::VersionSpecifiers;
|
||||
use uv_pypi_types::VerbatimParsedUrl;
|
||||
@@ -110,31 +110,31 @@ impl Pep723ItemRef<'_> {
|
||||
}
|
||||
|
||||
/// Collect any `tool.uv.index` from the script.
|
||||
pub fn indexes(&self, source_strategy: SourceStrategy) -> &[uv_distribution_types::Index] {
|
||||
pub fn indexes(&self, source_strategy: &NoSources) -> &[uv_distribution_types::Index] {
|
||||
match source_strategy {
|
||||
SourceStrategy::Enabled => self
|
||||
NoSources::None => self
|
||||
.metadata()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.top_level.index.as_deref())
|
||||
.unwrap_or(&[]),
|
||||
SourceStrategy::Disabled => &[],
|
||||
NoSources::All | NoSources::Packages(_) => &[],
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect any `tool.uv.sources` from the script.
|
||||
pub fn sources(&self, source_strategy: SourceStrategy) -> &BTreeMap<PackageName, Sources> {
|
||||
pub fn sources(&self, source_strategy: &NoSources) -> &BTreeMap<PackageName, Sources> {
|
||||
static EMPTY: BTreeMap<PackageName, Sources> = BTreeMap::new();
|
||||
match source_strategy {
|
||||
SourceStrategy::Enabled => self
|
||||
NoSources::None => self
|
||||
.metadata()
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.unwrap_or(&EMPTY),
|
||||
SourceStrategy::Disabled => &EMPTY,
|
||||
NoSources::All | NoSources::Packages(_) => &EMPTY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::{collections::BTreeMap, num::NonZeroUsize};
|
||||
use url::Url;
|
||||
|
||||
use uv_configuration::{
|
||||
BuildIsolation, ExportFormat, IndexStrategy, KeyringProviderType, ProxyUrl, Reinstall,
|
||||
RequiredVersion, TargetTriple, TrustedPublishing, Upgrade,
|
||||
BuildIsolation, ExportFormat, IndexStrategy, KeyringProviderType, NoSources, ProxyUrl,
|
||||
Reinstall, RequiredVersion, TargetTriple, TrustedPublishing, Upgrade,
|
||||
};
|
||||
use uv_distribution_types::{
|
||||
ConfigSettings, ExtraBuildVariables, Index, IndexUrl, PackageConfigSettings, PipExtraIndex,
|
||||
@@ -182,6 +182,16 @@ impl Combine for Option<PackageConfigSettings> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Combine for Option<NoSources> {
|
||||
/// Combine two source strategies by using the `combine` method if they're both `Some`.
|
||||
fn combine(self, other: Self) -> Self {
|
||||
match (self, other) {
|
||||
(Some(a), Some(b)) => Some(a.combine(b)),
|
||||
(a, b) => a.or(b),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Combine for Option<Upgrade> {
|
||||
fn combine(self, other: Self) -> Self {
|
||||
match (self, other) {
|
||||
|
||||
@@ -331,6 +331,7 @@ fn warn_uv_toml_masked_fields(options: &Options) {
|
||||
link_mode,
|
||||
compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package: _,
|
||||
upgrade,
|
||||
upgrade_package,
|
||||
reinstall,
|
||||
|
||||
@@ -382,6 +382,7 @@ pub struct InstallerOptions {
|
||||
pub no_binary: Option<bool>,
|
||||
pub no_binary_package: Option<Vec<PackageName>>,
|
||||
pub no_sources: Option<bool>,
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
}
|
||||
|
||||
/// Settings relevant to all resolver operations.
|
||||
@@ -412,6 +413,7 @@ pub struct ResolverOptions {
|
||||
pub extra_build_dependencies: Option<ExtraBuildDependencies>,
|
||||
pub extra_build_variables: Option<ExtraBuildVariables>,
|
||||
pub no_sources: Option<bool>,
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
}
|
||||
|
||||
/// Shared settings, relevant to all operations that must resolve and install dependencies. The
|
||||
@@ -440,6 +442,7 @@ pub struct ResolverInstallerOptions {
|
||||
pub torch_backend: Option<TorchMode>,
|
||||
pub compile_bytecode: Option<bool>,
|
||||
pub no_sources: Option<bool>,
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
pub upgrade: Option<Upgrade>,
|
||||
pub reinstall: Option<Reinstall>,
|
||||
pub no_build: Option<bool>,
|
||||
@@ -474,6 +477,7 @@ impl From<ResolverInstallerSchema> for ResolverInstallerOptions {
|
||||
torch_backend,
|
||||
compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
upgrade,
|
||||
upgrade_package,
|
||||
reinstall,
|
||||
@@ -509,6 +513,7 @@ impl From<ResolverInstallerSchema> for ResolverInstallerOptions {
|
||||
torch_backend,
|
||||
compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
upgrade: Upgrade::from_args(
|
||||
upgrade,
|
||||
upgrade_package
|
||||
@@ -920,6 +925,15 @@ pub struct ResolverInstallerSchema {
|
||||
"#
|
||||
)]
|
||||
pub no_sources: Option<bool>,
|
||||
/// Ignore `tool.uv.sources` for the specified packages.
|
||||
#[option(
|
||||
default = "[]",
|
||||
value_type = "list[str]",
|
||||
example = r#"
|
||||
no-sources-package = ["ruff"]
|
||||
"#
|
||||
)]
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
/// Allow package upgrades, ignoring pinned versions in any existing output file.
|
||||
#[option(
|
||||
default = "false",
|
||||
@@ -1811,6 +1825,15 @@ pub struct PipOptions {
|
||||
"#
|
||||
)]
|
||||
pub no_sources: Option<bool>,
|
||||
/// Ignore `tool.uv.sources` for the specified packages.
|
||||
#[option(
|
||||
default = "[]",
|
||||
value_type = "list[str]",
|
||||
example = r#"
|
||||
no-sources-package = ["ruff"]
|
||||
"#
|
||||
)]
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
/// Allow package upgrades, ignoring pinned versions in any existing output file.
|
||||
#[option(
|
||||
default = "false",
|
||||
@@ -1961,6 +1984,7 @@ impl From<ResolverInstallerSchema> for ResolverOptions {
|
||||
extra_build_dependencies: value.extra_build_dependencies,
|
||||
extra_build_variables: value.extra_build_variables,
|
||||
no_sources: value.no_sources,
|
||||
no_sources_package: value.no_sources_package,
|
||||
torch_backend: value.torch_backend,
|
||||
}
|
||||
}
|
||||
@@ -2002,6 +2026,7 @@ impl From<ResolverInstallerSchema> for InstallerOptions {
|
||||
no_binary: value.no_binary,
|
||||
no_binary_package: value.no_binary_package,
|
||||
no_sources: value.no_sources,
|
||||
no_sources_package: value.no_sources_package,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2037,6 +2062,7 @@ pub struct ToolOptions {
|
||||
pub link_mode: Option<LinkMode>,
|
||||
pub compile_bytecode: Option<bool>,
|
||||
pub no_sources: Option<bool>,
|
||||
pub no_sources_package: Option<Vec<PackageName>>,
|
||||
pub no_build: Option<bool>,
|
||||
pub no_build_package: Option<Vec<PackageName>>,
|
||||
pub no_binary: Option<bool>,
|
||||
@@ -2068,6 +2094,7 @@ impl From<ResolverInstallerOptions> for ToolOptions {
|
||||
link_mode: value.link_mode,
|
||||
compile_bytecode: value.compile_bytecode,
|
||||
no_sources: value.no_sources,
|
||||
no_sources_package: value.no_sources_package,
|
||||
no_build: value.no_build,
|
||||
no_build_package: value.no_build_package,
|
||||
no_binary: value.no_binary,
|
||||
@@ -2101,6 +2128,7 @@ impl From<ToolOptions> for ResolverInstallerOptions {
|
||||
link_mode: value.link_mode,
|
||||
compile_bytecode: value.compile_bytecode,
|
||||
no_sources: value.no_sources,
|
||||
no_sources_package: value.no_sources_package,
|
||||
upgrade: None,
|
||||
reinstall: None,
|
||||
no_build: value.no_build,
|
||||
@@ -2159,6 +2187,7 @@ pub struct OptionsWire {
|
||||
link_mode: Option<LinkMode>,
|
||||
compile_bytecode: Option<bool>,
|
||||
no_sources: Option<bool>,
|
||||
no_sources_package: Option<Vec<PackageName>>,
|
||||
upgrade: Option<bool>,
|
||||
upgrade_package: Option<Vec<Requirement<VerbatimParsedUrl>>>,
|
||||
reinstall: Option<bool>,
|
||||
@@ -2255,6 +2284,7 @@ impl From<OptionsWire> for Options {
|
||||
link_mode,
|
||||
compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
upgrade,
|
||||
upgrade_package,
|
||||
reinstall,
|
||||
@@ -2332,6 +2362,7 @@ impl From<OptionsWire> for Options {
|
||||
link_mode,
|
||||
compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
upgrade,
|
||||
upgrade_package,
|
||||
reinstall,
|
||||
|
||||
@@ -268,6 +268,11 @@ impl EnvVars {
|
||||
#[attr_added_in("0.6.5")]
|
||||
pub const UV_NO_BUILD_PACKAGE: &'static str = "UV_NO_BUILD_PACKAGE";
|
||||
|
||||
/// Equivalent to the `--no-sources-package` command line argument. If set, uv will
|
||||
/// ignore the `tool.uv.sources` table for the given space-delimited list of packages.
|
||||
#[attr_added_in("next release")]
|
||||
pub const UV_NO_SOURCES_PACKAGE: &'static str = "UV_NO_SOURCES_PACKAGE";
|
||||
|
||||
/// Equivalent to the `--publish-url` command-line argument. The URL of the upload
|
||||
/// endpoint of the index to use with `uv publish`.
|
||||
#[attr_added_in("0.4.16")]
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
|
||||
use dashmap::DashMap;
|
||||
|
||||
use uv_configuration::{BuildKind, SourceStrategy};
|
||||
use uv_configuration::{BuildKind, NoSources};
|
||||
use uv_normalize::PackageName;
|
||||
use uv_python::PythonEnvironment;
|
||||
|
||||
@@ -51,7 +51,7 @@ pub struct BuildKey {
|
||||
pub base_python: Box<Path>,
|
||||
pub source_root: Box<Path>,
|
||||
pub subdirectory: Option<Box<Path>>,
|
||||
pub source_strategy: SourceStrategy,
|
||||
pub no_sources: NoSources,
|
||||
pub build_kind: BuildKind,
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use anyhow::Result;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use uv_cache::Cache;
|
||||
use uv_configuration::{BuildKind, BuildOptions, BuildOutput, SourceStrategy};
|
||||
use uv_configuration::{BuildKind, BuildOptions, BuildOutput, NoSources};
|
||||
use uv_distribution_filename::DistFilename;
|
||||
use uv_distribution_types::{
|
||||
CachedDist, ConfigSettings, DependencyMetadata, DistributionId, ExtraBuildRequires,
|
||||
@@ -97,7 +97,7 @@ pub trait BuildContext {
|
||||
fn config_settings_package(&self) -> &PackageConfigSettings;
|
||||
|
||||
/// Whether to incorporate `tool.uv.sources` when resolving requirements.
|
||||
fn sources(&self) -> SourceStrategy;
|
||||
fn sources(&self) -> &NoSources;
|
||||
|
||||
/// The index locations being searched.
|
||||
fn locations(&self) -> &IndexLocations;
|
||||
@@ -141,7 +141,7 @@ pub trait BuildContext {
|
||||
install_path: &'a Path,
|
||||
version_id: Option<&'a str>,
|
||||
dist: Option<&'a SourceDist>,
|
||||
sources: SourceStrategy,
|
||||
sources: &'a NoSources,
|
||||
build_kind: BuildKind,
|
||||
build_output: BuildOutput,
|
||||
build_stack: BuildStack,
|
||||
@@ -158,7 +158,7 @@ pub trait BuildContext {
|
||||
source: &'a Path,
|
||||
subdirectory: Option<&'a Path>,
|
||||
output_dir: &'a Path,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
build_kind: BuildKind,
|
||||
version_id: Option<&'a str>,
|
||||
) -> impl Future<Output = Result<Option<DistFilename>, impl IsBuildBackendError>> + 'a;
|
||||
|
||||
@@ -15,8 +15,7 @@ use uv_cache::{Cache, CacheBucket};
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
BuildIsolation, BuildKind, BuildOptions, BuildOutput, Concurrency, Constraints,
|
||||
DependencyGroupsWithDefaults, HashCheckingMode, IndexStrategy, KeyringProviderType,
|
||||
SourceStrategy,
|
||||
DependencyGroupsWithDefaults, HashCheckingMode, IndexStrategy, KeyringProviderType, NoSources,
|
||||
};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
use uv_distribution::LoweredExtraBuildDependencies;
|
||||
@@ -358,7 +357,7 @@ async fn build_impl(
|
||||
*index_strategy,
|
||||
*keyring_provider,
|
||||
exclude_newer.clone(),
|
||||
*sources,
|
||||
sources.clone(),
|
||||
concurrency,
|
||||
build_options,
|
||||
sdist,
|
||||
@@ -467,7 +466,7 @@ async fn build_package(
|
||||
index_strategy: IndexStrategy,
|
||||
keyring_provider: KeyringProviderType,
|
||||
exclude_newer: ExcludeNewer,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
concurrency: Concurrency,
|
||||
build_options: &BuildOptions,
|
||||
sdist: bool,
|
||||
@@ -627,7 +626,7 @@ async fn build_package(
|
||||
build_options,
|
||||
&hasher,
|
||||
exclude_newer,
|
||||
sources,
|
||||
sources.clone(),
|
||||
workspace_cache,
|
||||
concurrency,
|
||||
preview,
|
||||
@@ -687,7 +686,7 @@ async fn build_package(
|
||||
printer,
|
||||
"source distribution",
|
||||
&build_dispatch,
|
||||
sources,
|
||||
&sources,
|
||||
dist,
|
||||
subdirectory,
|
||||
version_id,
|
||||
@@ -704,7 +703,7 @@ async fn build_package(
|
||||
printer,
|
||||
"source distribution",
|
||||
&build_dispatch,
|
||||
sources,
|
||||
&sources,
|
||||
dist,
|
||||
subdirectory,
|
||||
version_id,
|
||||
@@ -756,7 +755,7 @@ async fn build_package(
|
||||
printer,
|
||||
"source distribution",
|
||||
&build_dispatch,
|
||||
sources,
|
||||
&sources,
|
||||
dist,
|
||||
subdirectory,
|
||||
version_id,
|
||||
@@ -794,7 +793,7 @@ async fn build_package(
|
||||
printer,
|
||||
"source distribution",
|
||||
&build_dispatch,
|
||||
sources,
|
||||
&sources,
|
||||
dist,
|
||||
subdirectory,
|
||||
version_id,
|
||||
@@ -903,7 +902,7 @@ async fn build_sdist(
|
||||
build_kind_message: &str,
|
||||
// Below is only used with PEP 517 builds
|
||||
build_dispatch: &BuildDispatch<'_>,
|
||||
sources: SourceStrategy,
|
||||
sources: &NoSources,
|
||||
dist: Option<&SourceDist>,
|
||||
subdirectory: Option<&Path>,
|
||||
version_id: Option<&str>,
|
||||
@@ -912,11 +911,12 @@ async fn build_sdist(
|
||||
let build_result = match action {
|
||||
BuildAction::List => {
|
||||
let source_tree_ = source_tree.to_path_buf();
|
||||
let sources_enabled = sources.is_none();
|
||||
let (filename, file_list) = tokio::task::spawn_blocking(move || {
|
||||
uv_build_backend::list_source_dist(
|
||||
&source_tree_,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources_enabled,
|
||||
)
|
||||
})
|
||||
.await??;
|
||||
@@ -941,12 +941,13 @@ async fn build_sdist(
|
||||
)?;
|
||||
let source_tree = source_tree.to_path_buf();
|
||||
let output_dir_ = output_dir.to_path_buf();
|
||||
let sources_enabled = sources.is_none();
|
||||
let filename = tokio::task::spawn_blocking(move || {
|
||||
uv_build_backend::build_source_dist(
|
||||
&source_tree,
|
||||
&output_dir_,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources_enabled,
|
||||
)
|
||||
})
|
||||
.await??
|
||||
@@ -1011,7 +1012,7 @@ async fn build_wheel(
|
||||
build_kind_message: &str,
|
||||
// Below is only used with PEP 517 builds
|
||||
build_dispatch: &BuildDispatch<'_>,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
dist: Option<&SourceDist>,
|
||||
subdirectory: Option<&Path>,
|
||||
version_id: Option<&str>,
|
||||
@@ -1023,11 +1024,12 @@ async fn build_wheel(
|
||||
let build_message = match action {
|
||||
BuildAction::List => {
|
||||
let source_tree_ = source_tree.to_path_buf();
|
||||
let sources_enabled = sources.is_none();
|
||||
let (filename, file_list) = tokio::task::spawn_blocking(move || {
|
||||
uv_build_backend::list_wheel(
|
||||
&source_tree_,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources_enabled,
|
||||
preview,
|
||||
)
|
||||
})
|
||||
@@ -1053,13 +1055,14 @@ async fn build_wheel(
|
||||
)?;
|
||||
let source_tree = source_tree.to_path_buf();
|
||||
let output_dir_ = output_dir.to_path_buf();
|
||||
let sources_enabled = sources.is_none();
|
||||
let filename = tokio::task::spawn_blocking(move || {
|
||||
uv_build_backend::build_wheel(
|
||||
&source_tree,
|
||||
&output_dir_,
|
||||
None,
|
||||
uv_version::version(),
|
||||
sources == SourceStrategy::Enabled,
|
||||
sources_enabled,
|
||||
preview,
|
||||
)
|
||||
})
|
||||
@@ -1090,7 +1093,7 @@ async fn build_wheel(
|
||||
source.path(),
|
||||
version_id,
|
||||
dist,
|
||||
sources,
|
||||
&sources,
|
||||
BuildKind::Wheel,
|
||||
build_output,
|
||||
BuildStack::default(),
|
||||
|
||||
@@ -17,7 +17,7 @@ use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
BuildIsolation, BuildOptions, Concurrency, Constraints, ExtrasSpecification, IndexStrategy,
|
||||
NoBinary, NoBuild, PipCompileFormat, Reinstall, SourceStrategy, Upgrade,
|
||||
NoBinary, NoBuild, NoSources, PipCompileFormat, Reinstall, Upgrade,
|
||||
};
|
||||
use uv_configuration::{KeyringProviderType, TargetTriple};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
@@ -113,7 +113,7 @@ pub(crate) async fn pip_compile(
|
||||
python_downloads: PythonDownloads,
|
||||
universal: bool,
|
||||
exclude_newer: ExcludeNewer,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
annotation_style: AnnotationStyle,
|
||||
link_mode: LinkMode,
|
||||
mut python: Option<String>,
|
||||
|
||||
@@ -9,7 +9,7 @@ use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
BuildIsolation, BuildOptions, Concurrency, Constraints, DryRun, ExtrasSpecification,
|
||||
HashCheckingMode, IndexStrategy, Reinstall, SourceStrategy, Upgrade,
|
||||
HashCheckingMode, IndexStrategy, NoSources, Reinstall, Upgrade,
|
||||
};
|
||||
use uv_configuration::{KeyringProviderType, TargetTriple};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
@@ -91,7 +91,7 @@ pub(crate) async fn pip_install(
|
||||
install_mirrors: PythonInstallMirrors,
|
||||
strict: bool,
|
||||
exclude_newer: ExcludeNewer,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
python: Option<String>,
|
||||
system: bool,
|
||||
break_system_packages: bool,
|
||||
@@ -493,7 +493,7 @@ pub(crate) async fn pip_install(
|
||||
&build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
sources,
|
||||
sources.clone(),
|
||||
WorkspaceCache::default(),
|
||||
concurrency,
|
||||
preview,
|
||||
|
||||
@@ -217,7 +217,7 @@ pub(crate) async fn resolve<InstalledPackages: InstalledPackagesProvider>(
|
||||
pyproject_path,
|
||||
None,
|
||||
build_dispatch.locations(),
|
||||
build_dispatch.sources(),
|
||||
build_dispatch.sources().clone(),
|
||||
build_dispatch.workspace_cache(),
|
||||
client.credentials_cache(),
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
BuildIsolation, BuildOptions, Concurrency, Constraints, DryRun, ExtrasSpecification,
|
||||
HashCheckingMode, IndexStrategy, Reinstall, SourceStrategy, Upgrade,
|
||||
HashCheckingMode, IndexStrategy, NoSources, Reinstall, Upgrade,
|
||||
};
|
||||
use uv_configuration::{KeyringProviderType, TargetTriple};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
@@ -85,7 +85,7 @@ pub(crate) async fn pip_sync(
|
||||
break_system_packages: bool,
|
||||
target: Option<Target>,
|
||||
prefix: Option<Prefix>,
|
||||
sources: SourceStrategy,
|
||||
sources: NoSources,
|
||||
python_preference: PythonPreference,
|
||||
concurrency: Concurrency,
|
||||
cache: Cache,
|
||||
@@ -400,7 +400,7 @@ pub(crate) async fn pip_sync(
|
||||
&build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
sources,
|
||||
sources.clone(),
|
||||
WorkspaceCache::default(),
|
||||
concurrency,
|
||||
preview,
|
||||
|
||||
@@ -17,8 +17,7 @@ use uv_cache_key::RepositoryUrl;
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
Concurrency, Constraints, DependencyGroups, DependencyGroupsWithDefaults, DevMode, DryRun,
|
||||
ExtrasSpecification, ExtrasSpecificationWithDefaults, GitLfsSetting, InstallOptions,
|
||||
SourceStrategy,
|
||||
ExtrasSpecification, ExtrasSpecificationWithDefaults, GitLfsSetting, InstallOptions, NoSources,
|
||||
};
|
||||
use uv_dispatch::BuildDispatch;
|
||||
use uv_distribution::{DistributionDatabase, LoweredExtraBuildDependencies};
|
||||
@@ -396,7 +395,7 @@ pub(crate) async fn add(
|
||||
let build_constraints = Constraints::default();
|
||||
let build_hasher = HashStrategy::default();
|
||||
let hasher = HashStrategy::default();
|
||||
let sources = SourceStrategy::Enabled;
|
||||
let sources = NoSources::None;
|
||||
|
||||
// Initialize the registry client.
|
||||
let client = RegistryClientBuilder::new(client_builder.clone(), cache.clone())
|
||||
@@ -442,7 +441,7 @@ pub(crate) async fn add(
|
||||
settings.resolver.extra_build_dependencies.clone(),
|
||||
project.workspace(),
|
||||
&settings.resolver.index_locations,
|
||||
settings.resolver.sources,
|
||||
&settings.resolver.sources,
|
||||
client.credentials_cache(),
|
||||
)?
|
||||
} else {
|
||||
|
||||
@@ -498,25 +498,25 @@ async fn do_lock(
|
||||
let requirements = target.lower(
|
||||
requirements,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?;
|
||||
let overrides = target.lower(
|
||||
overrides,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?;
|
||||
let constraints = target.lower(
|
||||
constraints,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?;
|
||||
let build_constraints = target.lower(
|
||||
build_constraints,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?;
|
||||
let dependency_groups = dependency_groups
|
||||
@@ -525,7 +525,7 @@ async fn do_lock(
|
||||
let requirements = target.lower(
|
||||
group.requirements,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?;
|
||||
Ok((name, requirements))
|
||||
@@ -741,7 +741,7 @@ async fn do_lock(
|
||||
extra_build_dependencies.clone(),
|
||||
workspace,
|
||||
index_locations,
|
||||
*sources,
|
||||
sources,
|
||||
client.credentials_cache(),
|
||||
)?,
|
||||
LockTarget::Script(script) => {
|
||||
@@ -774,7 +774,7 @@ async fn do_lock(
|
||||
build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
*sources,
|
||||
sources.clone(),
|
||||
workspace_cache.clone(),
|
||||
concurrency,
|
||||
preview,
|
||||
|
||||
@@ -2,8 +2,9 @@ use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use itertools::Either;
|
||||
|
||||
use uv_auth::CredentialsCache;
|
||||
use uv_configuration::{DependencyGroupsWithDefaults, SourceStrategy};
|
||||
use uv_configuration::{DependencyGroupsWithDefaults, NoSources};
|
||||
use uv_distribution::LoweredRequirement;
|
||||
use uv_distribution_types::{Index, IndexLocations, Requirement, RequiresPython};
|
||||
use uv_normalize::{GroupName, PackageName};
|
||||
@@ -342,7 +343,7 @@ impl<'lock> LockTarget<'lock> {
|
||||
self,
|
||||
requirements: Vec<uv_pep508::Requirement<VerbatimParsedUrl>>,
|
||||
locations: &IndexLocations,
|
||||
sources: SourceStrategy,
|
||||
sources: &NoSources,
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<Vec<Requirement>, uv_distribution::MetadataError> {
|
||||
match self {
|
||||
@@ -375,49 +376,50 @@ impl<'lock> LockTarget<'lock> {
|
||||
Self::Script(script) => {
|
||||
// Collect any `tool.uv.index` from the script.
|
||||
let empty = Vec::default();
|
||||
let indexes = match sources {
|
||||
SourceStrategy::Enabled => script
|
||||
.metadata
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.top_level.index.as_deref())
|
||||
.unwrap_or(&empty),
|
||||
SourceStrategy::Disabled => &empty,
|
||||
};
|
||||
let indexes = script
|
||||
.metadata
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.top_level.index.as_deref())
|
||||
.unwrap_or(&empty);
|
||||
|
||||
// Collect any `tool.uv.sources` from the script.
|
||||
let empty = BTreeMap::default();
|
||||
let sources = match 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 sources_map = script
|
||||
.metadata
|
||||
.tool
|
||||
.as_ref()
|
||||
.and_then(|tool| tool.uv.as_ref())
|
||||
.and_then(|uv| uv.sources.as_ref())
|
||||
.unwrap_or(&empty);
|
||||
|
||||
Ok(requirements
|
||||
.into_iter()
|
||||
.flat_map(|requirement| {
|
||||
let requirement_name = requirement.name.clone();
|
||||
LoweredRequirement::from_non_workspace_requirement(
|
||||
requirement,
|
||||
script.path.parent().unwrap(),
|
||||
sources,
|
||||
indexes,
|
||||
locations,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(uv_distribution::MetadataError::LoweringError(
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
// Check if sources should be disabled for this specific package
|
||||
if sources.for_package(&requirement.name) {
|
||||
vec![Ok(Requirement::from(requirement))].into_iter()
|
||||
} else {
|
||||
let requirement_name = requirement.name.clone();
|
||||
LoweredRequirement::from_non_workspace_requirement(
|
||||
requirement,
|
||||
script.path.parent().unwrap(),
|
||||
sources_map,
|
||||
indexes,
|
||||
locations,
|
||||
credentials_cache,
|
||||
)
|
||||
.map(move |requirement| match requirement {
|
||||
Ok(requirement) => Ok(requirement.into_inner()),
|
||||
Err(err) => Err(uv_distribution::MetadataError::LoweringError(
|
||||
requirement_name.clone(),
|
||||
Box::new(err),
|
||||
)),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}
|
||||
})
|
||||
.collect::<Result<_, _>>()?)
|
||||
}
|
||||
|
||||
@@ -1862,7 +1862,7 @@ pub(crate) async fn resolve_names(
|
||||
build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
*sources,
|
||||
sources.clone(),
|
||||
workspace_cache.clone(),
|
||||
concurrency,
|
||||
preview,
|
||||
@@ -2098,7 +2098,7 @@ pub(crate) async fn resolve_environment(
|
||||
build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
*sources,
|
||||
sources.clone(),
|
||||
workspace_cache,
|
||||
concurrency,
|
||||
preview,
|
||||
@@ -2493,7 +2493,7 @@ pub(crate) async fn update_environment(
|
||||
build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
*sources,
|
||||
sources.clone(),
|
||||
workspace_cache,
|
||||
concurrency,
|
||||
preview,
|
||||
@@ -2707,8 +2707,8 @@ pub(crate) fn script_specification(
|
||||
};
|
||||
|
||||
let script_dir = script.directory()?;
|
||||
let script_indexes = script.indexes(settings.sources);
|
||||
let script_sources = script.sources(settings.sources);
|
||||
let script_indexes = script.indexes(&settings.sources);
|
||||
let script_sources = script.sources(&settings.sources);
|
||||
|
||||
let requirements = dependencies
|
||||
.iter()
|
||||
@@ -2783,8 +2783,8 @@ pub(crate) fn script_extra_build_requires(
|
||||
credentials_cache: &CredentialsCache,
|
||||
) -> Result<LoweredExtraBuildDependencies, ProjectError> {
|
||||
let script_dir = script.directory()?;
|
||||
let script_indexes = script.indexes(settings.sources);
|
||||
let script_sources = script.sources(settings.sources);
|
||||
let script_indexes = script.indexes(&settings.sources);
|
||||
let script_sources = script.sources(&settings.sources);
|
||||
|
||||
// Collect any `tool.uv.extra-build-dependencies` from the script.
|
||||
let empty = BTreeMap::default();
|
||||
|
||||
@@ -661,7 +661,7 @@ pub(super) async fn do_sync(
|
||||
extra_build_dependencies.clone(),
|
||||
workspace,
|
||||
index_locations,
|
||||
sources,
|
||||
&sources,
|
||||
client_builder.credentials_cache(),
|
||||
)?
|
||||
}
|
||||
@@ -683,7 +683,7 @@ pub(super) async fn do_sync(
|
||||
extra_build_variables: extra_build_variables.clone(),
|
||||
prerelease: PrereleaseMode::default(),
|
||||
resolution: ResolutionMode::default(),
|
||||
sources,
|
||||
sources: sources.clone(),
|
||||
torch_backend: None,
|
||||
upgrade: Upgrade::default(),
|
||||
};
|
||||
@@ -825,7 +825,7 @@ pub(super) async fn do_sync(
|
||||
build_options,
|
||||
&build_hasher,
|
||||
exclude_newer.clone(),
|
||||
sources,
|
||||
sources.clone(),
|
||||
workspace_cache.clone(),
|
||||
concurrency,
|
||||
preview,
|
||||
|
||||
@@ -11,7 +11,7 @@ use uv_cache::Cache;
|
||||
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
|
||||
use uv_configuration::{
|
||||
BuildOptions, Concurrency, Constraints, DependencyGroups, DryRun, IndexStrategy,
|
||||
KeyringProviderType, NoBinary, NoBuild, SourceStrategy,
|
||||
KeyringProviderType, NoBinary, NoBuild, NoSources,
|
||||
};
|
||||
use uv_dispatch::{BuildDispatch, SharedState};
|
||||
use uv_distribution_types::{
|
||||
@@ -248,7 +248,7 @@ pub(crate) async fn venv(
|
||||
let build_hasher = HashStrategy::default();
|
||||
let config_settings = ConfigSettings::default();
|
||||
let config_settings_package = PackageConfigSettings::default();
|
||||
let sources = SourceStrategy::Disabled;
|
||||
let sources = NoSources::All;
|
||||
|
||||
// Do not allow builds
|
||||
let build_options = BuildOptions::new(NoBinary::None, NoBuild::All);
|
||||
|
||||
+24
-10
@@ -30,8 +30,8 @@ use uv_client::Connectivity;
|
||||
use uv_configuration::{
|
||||
BuildIsolation, BuildOptions, Concurrency, DependencyGroups, DryRun, EditableMode, EnvFile,
|
||||
ExportFormat, ExtrasSpecification, GitLfsSetting, HashCheckingMode, IndexStrategy,
|
||||
InstallOptions, KeyringProviderType, NoBinary, NoBuild, PipCompileFormat, ProjectBuildBackend,
|
||||
ProxyUrl, Reinstall, RequiredVersion, SourceStrategy, TargetTriple, TrustedHost,
|
||||
InstallOptions, KeyringProviderType, NoBinary, NoBuild, NoSources, PipCompileFormat,
|
||||
ProjectBuildBackend, ProxyUrl, Reinstall, RequiredVersion, TargetTriple, TrustedHost,
|
||||
TrustedPublishing, Upgrade, VersionControlSystem,
|
||||
};
|
||||
use uv_distribution_types::{
|
||||
@@ -1016,6 +1016,7 @@ impl ToolUpgradeSettings {
|
||||
compile_bytecode,
|
||||
no_compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
exclude_newer_package,
|
||||
build,
|
||||
} = args;
|
||||
@@ -1053,6 +1054,7 @@ impl ToolUpgradeSettings {
|
||||
compile_bytecode,
|
||||
no_compile_bytecode,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
};
|
||||
|
||||
let args = resolver_installer_options(installer, build);
|
||||
@@ -3448,7 +3450,7 @@ pub(crate) struct InstallerSettingsRef<'a> {
|
||||
pub(crate) compile_bytecode: bool,
|
||||
pub(crate) reinstall: &'a Reinstall,
|
||||
pub(crate) build_options: &'a BuildOptions,
|
||||
pub(crate) sources: SourceStrategy,
|
||||
pub(crate) sources: NoSources,
|
||||
}
|
||||
|
||||
/// The resolved settings to use for an invocation of the uv CLI when resolving dependencies.
|
||||
@@ -3472,7 +3474,7 @@ pub(crate) struct ResolverSettings {
|
||||
pub(crate) extra_build_variables: ExtraBuildVariables,
|
||||
pub(crate) prerelease: PrereleaseMode,
|
||||
pub(crate) resolution: ResolutionMode,
|
||||
pub(crate) sources: SourceStrategy,
|
||||
pub(crate) sources: NoSources,
|
||||
pub(crate) torch_backend: Option<TorchMode>,
|
||||
pub(crate) upgrade: Upgrade,
|
||||
}
|
||||
@@ -3529,7 +3531,10 @@ impl From<ResolverOptions> for ResolverSettings {
|
||||
exclude_newer: value.exclude_newer,
|
||||
link_mode: value.link_mode.unwrap_or_default(),
|
||||
torch_backend: value.torch_backend,
|
||||
sources: SourceStrategy::from_args(value.no_sources.unwrap_or_default()),
|
||||
sources: NoSources::from_args(
|
||||
value.no_sources,
|
||||
value.no_sources_package.unwrap_or_default(),
|
||||
),
|
||||
upgrade: value.upgrade.unwrap_or_default(),
|
||||
build_options: BuildOptions::new(
|
||||
NoBinary::from_args(value.no_binary, value.no_binary_package.unwrap_or_default()),
|
||||
@@ -3619,7 +3624,10 @@ impl From<ResolverInstallerOptions> for ResolverInstallerSettings {
|
||||
extra_build_variables: value.extra_build_variables.unwrap_or_default(),
|
||||
prerelease: value.prerelease.unwrap_or_default(),
|
||||
resolution: value.resolution.unwrap_or_default(),
|
||||
sources: SourceStrategy::from_args(value.no_sources.unwrap_or_default()),
|
||||
sources: NoSources::from_args(
|
||||
value.no_sources,
|
||||
value.no_sources_package.unwrap_or_default(),
|
||||
),
|
||||
torch_backend: value.torch_backend,
|
||||
upgrade: value.upgrade.unwrap_or_default(),
|
||||
},
|
||||
@@ -3680,7 +3688,7 @@ pub(crate) struct PipSettings {
|
||||
pub(crate) annotation_style: AnnotationStyle,
|
||||
pub(crate) link_mode: LinkMode,
|
||||
pub(crate) compile_bytecode: bool,
|
||||
pub(crate) sources: SourceStrategy,
|
||||
pub(crate) sources: NoSources,
|
||||
pub(crate) hash_checking: Option<HashCheckingMode>,
|
||||
pub(crate) upgrade: Upgrade,
|
||||
pub(crate) reinstall: Reinstall,
|
||||
@@ -3759,6 +3767,7 @@ impl PipSettings {
|
||||
require_hashes,
|
||||
verify_hashes,
|
||||
no_sources,
|
||||
no_sources_package,
|
||||
upgrade,
|
||||
upgrade_package,
|
||||
reinstall,
|
||||
@@ -3788,6 +3797,7 @@ impl PipSettings {
|
||||
link_mode: top_level_link_mode,
|
||||
compile_bytecode: top_level_compile_bytecode,
|
||||
no_sources: top_level_no_sources,
|
||||
no_sources_package: top_level_no_sources_package,
|
||||
upgrade: top_level_upgrade,
|
||||
upgrade_package: top_level_upgrade_package,
|
||||
reinstall: top_level_reinstall,
|
||||
@@ -3836,6 +3846,7 @@ impl PipSettings {
|
||||
let link_mode = link_mode.combine(top_level_link_mode);
|
||||
let compile_bytecode = compile_bytecode.combine(top_level_compile_bytecode);
|
||||
let no_sources = no_sources.combine(top_level_no_sources);
|
||||
let no_sources_package = no_sources_package.combine(top_level_no_sources_package);
|
||||
let upgrade = upgrade.combine(top_level_upgrade);
|
||||
let upgrade_package = upgrade_package.combine(top_level_upgrade_package);
|
||||
let reinstall = reinstall.combine(top_level_reinstall);
|
||||
@@ -3994,8 +4005,11 @@ impl PipSettings {
|
||||
.compile_bytecode
|
||||
.combine(compile_bytecode)
|
||||
.unwrap_or_default(),
|
||||
sources: SourceStrategy::from_args(
|
||||
args.no_sources.combine(no_sources).unwrap_or_default(),
|
||||
sources: NoSources::from_args(
|
||||
args.no_sources.combine(no_sources),
|
||||
args.no_sources_package
|
||||
.combine(no_sources_package)
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
strict: args.strict.combine(strict).unwrap_or_default(),
|
||||
upgrade: Upgrade::from_args(
|
||||
@@ -4063,7 +4077,7 @@ impl<'a> From<&'a ResolverInstallerSettings> for InstallerSettingsRef<'a> {
|
||||
compile_bytecode: settings.compile_bytecode,
|
||||
reinstall: &settings.reinstall,
|
||||
build_options: &settings.resolver.build_options,
|
||||
sources: settings.resolver.sources,
|
||||
sources: settings.resolver.sources.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13706,6 +13706,448 @@ fn lock_mismatched_versions() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test that `--no-sources-package` allows selectively disabling sources for specific packages.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn lock_no_sources_package() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"anyio",
|
||||
"iniconfig"
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
// Lock with sources disabled only for anyio
|
||||
uv_snapshot!(context.filters(), context.lock().arg("--no-sources-package").arg("anyio"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
"###);
|
||||
|
||||
let lock = context.read("uv.lock");
|
||||
|
||||
insta::with_settings!({
|
||||
filters => context.filters(),
|
||||
}, {
|
||||
assert_snapshot!(
|
||||
lock, @r#"
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[options]
|
||||
exclude-newer = "2024-03-25T00:00:00Z"
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
version = "4.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "idna" },
|
||||
{ name = "sniffio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642, upload-time = "2024-02-19T08:36:28.641Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8", size = 85584, upload-time = "2024-02-19T08:36:26.842Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bf/3f/ea4b9117521a1e9c50344b909be7886dd00a519552724809bb1f486986c2/idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca", size = 175426, upload-time = "2023-11-25T15:40:54.902Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f", size = 61567, upload-time = "2023-11-25T15:40:52.604Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
source = { git = "https://github.com/pytest-dev/iniconfig?tag=v2.0.0#93f5930e668c0d1ddf4597e38dd0dea4e2665e7a" }
|
||||
|
||||
[[package]]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig", git = "https://github.com/pytest-dev/iniconfig?tag=v2.0.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
"#
|
||||
);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test that `--no-sources-package` works with multiple packages.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn lock_no_sources_package_multiple() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"anyio",
|
||||
"iniconfig",
|
||||
"typing-extensions"
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
typing-extensions = { git = "https://github.com/python/typing_extensions", tag = "4.12.0" }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
// Lock with sources disabled for two packages
|
||||
uv_snapshot!(context.filters(), context.lock().arg("--no-sources-package").arg("anyio typing-extensions"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 6 packages in [TIME]
|
||||
"###);
|
||||
|
||||
let lock = context.read("uv.lock");
|
||||
|
||||
insta::with_settings!({
|
||||
filters => context.filters(),
|
||||
}, {
|
||||
assert_snapshot!(
|
||||
lock, @r#"
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[options]
|
||||
exclude-newer = "2024-03-25T00:00:00Z"
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
version = "4.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "idna" },
|
||||
{ name = "sniffio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642, upload-time = "2024-02-19T08:36:28.641Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8", size = 85584, upload-time = "2024-02-19T08:36:26.842Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bf/3f/ea4b9117521a1e9c50344b909be7886dd00a519552724809bb1f486986c2/idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca", size = 175426, upload-time = "2023-11-25T15:40:54.902Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f", size = 61567, upload-time = "2023-11-25T15:40:52.604Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
source = { git = "https://github.com/pytest-dev/iniconfig?tag=v2.0.0#93f5930e668c0d1ddf4597e38dd0dea4e2665e7a" }
|
||||
|
||||
[[package]]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig", git = "https://github.com/pytest-dev/iniconfig?tag=v2.0.0" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.10.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/16/3a/0d26ce356c7465a19c9ea8814b960f8a36c3b0d07c323176620b7b483e44/typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb", size = 77558, upload-time = "2024-02-25T22:12:49.693Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f9/de/dc04a3ea60b22624b51c703a84bbe0184abcd1d0b9bc8074b5d6b7ab90bb/typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475", size = 33926, upload-time = "2024-02-25T22:12:47.72Z" },
|
||||
]
|
||||
"#
|
||||
);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test that `--no-sources` takes precedence over `--no-sources-package`.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn lock_no_sources_with_no_sources_package() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"anyio",
|
||||
"iniconfig"
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
// Lock with both --no-sources and --no-sources-package
|
||||
// --no-sources should take precedence and disable all sources
|
||||
uv_snapshot!(context.filters(), context.lock().arg("--no-sources").arg("--no-sources-package").arg("iniconfig"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
"###);
|
||||
|
||||
let lock = context.read("uv.lock");
|
||||
|
||||
insta::with_settings!({
|
||||
filters => context.filters(),
|
||||
}, {
|
||||
assert_snapshot!(
|
||||
lock, @r#"
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[options]
|
||||
exclude-newer = "2024-03-25T00:00:00Z"
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
version = "4.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "idna" },
|
||||
{ name = "sniffio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642, upload-time = "2024-02-19T08:36:28.641Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8", size = 85584, upload-time = "2024-02-19T08:36:26.842Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bf/3f/ea4b9117521a1e9c50344b909be7886dd00a519552724809bb1f486986c2/idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca", size = 175426, upload-time = "2023-11-25T15:40:54.902Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f", size = 61567, upload-time = "2023-11-25T15:40:52.604Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646, upload-time = "2023-01-07T11:08:11.254Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892, upload-time = "2023-01-07T11:08:09.864Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
"#
|
||||
);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test that `UV_NO_SOURCES_PACKAGE` environment variable works.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn lock_no_sources_package_env_var() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"anyio",
|
||||
"iniconfig"
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
// Lock with UV_NO_SOURCES_PACKAGE environment variable
|
||||
uv_snapshot!(context.filters(), context.lock().env("UV_NO_SOURCES_PACKAGE", "anyio iniconfig"), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
"###);
|
||||
|
||||
let lock = context.read("uv.lock");
|
||||
|
||||
insta::with_settings!({
|
||||
filters => context.filters(),
|
||||
}, {
|
||||
assert_snapshot!(
|
||||
lock, @r#"
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[options]
|
||||
exclude-newer = "2024-03-25T00:00:00Z"
|
||||
|
||||
[[package]]
|
||||
name = "anyio"
|
||||
version = "4.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "idna" },
|
||||
{ name = "sniffio" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642, upload-time = "2024-02-19T08:36:28.641Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8", size = 85584, upload-time = "2024-02-19T08:36:26.842Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bf/3f/ea4b9117521a1e9c50344b909be7886dd00a519552724809bb1f486986c2/idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca", size = 175426, upload-time = "2023-11-25T15:40:54.902Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f", size = 61567, upload-time = "2023-11-25T15:40:52.604Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "2.0.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646, upload-time = "2023-01-07T11:08:11.254Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892, upload-time = "2023-01-07T11:08:09.864Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "anyio" },
|
||||
{ name = "iniconfig" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.3.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" },
|
||||
]
|
||||
"#
|
||||
);
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// This checks that overlapping marker expressions with disjoint
|
||||
/// version constraints fails to resolve.
|
||||
#[test]
|
||||
|
||||
@@ -10949,6 +10949,57 @@ fn no_sources_workspace_discovery() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test `--no-sources-package` with pip install to selectively disable sources.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn pip_install_no_sources_package() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
context.temp_dir.child("pyproject.toml").write_str(indoc! {
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
dependencies = ["anyio", "iniconfig"]
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
"#
|
||||
})?;
|
||||
context
|
||||
.temp_dir
|
||||
.child("src")
|
||||
.child("project")
|
||||
.child("__init__.py")
|
||||
.touch()?;
|
||||
|
||||
// Install with sources disabled for anyio only
|
||||
uv_snapshot!(context.filters(), context.pip_install()
|
||||
.arg("--no-sources-package")
|
||||
.arg("anyio")
|
||||
.arg("."), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
Prepared 5 packages in [TIME]
|
||||
Installed 5 packages in [TIME]
|
||||
+ anyio==4.3.0
|
||||
+ idna==3.6
|
||||
+ iniconfig==2.0.0 (from git+https://github.com/pytest-dev/iniconfig@93f5930e668c0d1ddf4597e38dd0dea4e2665e7a)
|
||||
+ project==0.1.0 (from file://[TEMP_DIR]/)
|
||||
+ sniffio==1.3.1
|
||||
"###);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_git_scheme() {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
@@ -243,7 +243,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -450,7 +450,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -658,7 +658,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -898,7 +898,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -1073,7 +1073,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -1294,7 +1294,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -1559,7 +1559,7 @@ fn resolve_index_url() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -1836,7 +1836,7 @@ fn resolve_index_url() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -2068,7 +2068,7 @@ fn resolve_find_links() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -2265,7 +2265,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -2522,7 +2522,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -2762,7 +2762,7 @@ fn resolve_top_level() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -2958,7 +2958,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -3138,7 +3138,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -3318,7 +3318,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -3500,7 +3500,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -3636,6 +3636,7 @@ fn resolve_tool() -> anyhow::Result<()> {
|
||||
torch_backend: None,
|
||||
compile_bytecode: None,
|
||||
no_sources: None,
|
||||
no_sources_package: None,
|
||||
upgrade: None,
|
||||
reinstall: None,
|
||||
no_build: None,
|
||||
@@ -3682,7 +3683,7 @@ fn resolve_tool() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: LowestDirect,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -3896,7 +3897,7 @@ fn resolve_poetry_toml() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -4144,7 +4145,7 @@ fn resolve_both() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -4397,7 +4398,7 @@ fn resolve_both_special_fields() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -4729,7 +4730,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -4770,7 +4771,7 @@ fn resolve_config_file() -> anyhow::Result<()> {
|
||||
|
|
||||
1 | [project]
|
||||
| ^^^^^^^
|
||||
unknown field `project`, expected one of `required-version`, `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `http-proxy`, `https-proxy`, `no-proxy`, `allow-insecure-host`, `resolution`, `prerelease`, `fork-strategy`, `dependency-metadata`, `config-settings`, `config-settings-package`, `no-build-isolation`, `no-build-isolation-package`, `extra-build-dependencies`, `extra-build-variables`, `exclude-newer`, `exclude-newer-package`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `torch-backend`, `python-install-mirror`, `pypy-install-mirror`, `python-downloads-json-url`, `publish-url`, `trusted-publishing`, `check-url`, `add-bounds`, `pip`, `cache-keys`, `override-dependencies`, `exclude-dependencies`, `constraint-dependencies`, `build-constraint-dependencies`, `environments`, `required-environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dependency-groups`, `dev-dependencies`, `build-backend`
|
||||
unknown field `project`, expected one of `required-version`, `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `http-proxy`, `https-proxy`, `no-proxy`, `allow-insecure-host`, `resolution`, `prerelease`, `fork-strategy`, `dependency-metadata`, `config-settings`, `config-settings-package`, `no-build-isolation`, `no-build-isolation-package`, `extra-build-dependencies`, `extra-build-variables`, `exclude-newer`, `exclude-newer-package`, `link-mode`, `compile-bytecode`, `no-sources`, `no-sources-package`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `torch-backend`, `python-install-mirror`, `pypy-install-mirror`, `python-downloads-json-url`, `publish-url`, `trusted-publishing`, `check-url`, `add-bounds`, `pip`, `cache-keys`, `override-dependencies`, `exclude-dependencies`, `constraint-dependencies`, `build-constraint-dependencies`, `environments`, `required-environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dependency-groups`, `dev-dependencies`, `build-backend`
|
||||
"
|
||||
);
|
||||
|
||||
@@ -5002,7 +5003,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -5185,7 +5186,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -5387,7 +5388,7 @@ fn allow_insecure_host() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -5650,7 +5651,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -5892,7 +5893,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -6140,7 +6141,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -6383,7 +6384,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -6633,7 +6634,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -6876,7 +6877,7 @@ fn index_priority() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -7063,7 +7064,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -7236,7 +7237,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: None,
|
||||
upgrade: None,
|
||||
reinstall: None,
|
||||
@@ -7407,7 +7408,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Require,
|
||||
),
|
||||
@@ -7580,7 +7581,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: None,
|
||||
upgrade: None,
|
||||
reinstall: None,
|
||||
@@ -7751,7 +7752,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: None,
|
||||
upgrade: None,
|
||||
reinstall: None,
|
||||
@@ -7923,7 +7924,7 @@ fn verify_hashes() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -8060,7 +8061,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8179,7 +8180,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8298,7 +8299,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8417,7 +8418,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8536,7 +8537,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8657,7 +8658,7 @@ fn preview_features() {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -8847,7 +8848,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9028,7 +9029,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9232,7 +9233,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9411,7 +9412,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9584,7 +9585,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9758,7 +9759,7 @@ fn upgrade_pip_cli_config_interaction() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -9940,7 +9941,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -10064,7 +10065,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: Packages(
|
||||
{
|
||||
@@ -10211,7 +10212,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: All,
|
||||
},
|
||||
@@ -10333,7 +10334,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: None,
|
||||
},
|
||||
@@ -10445,7 +10446,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: All,
|
||||
},
|
||||
@@ -10558,7 +10559,7 @@ fn upgrade_project_cli_config_interaction() -> anyhow::Result<()> {
|
||||
),
|
||||
prerelease: IfNecessaryOrExplicit,
|
||||
resolution: Highest,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
torch_backend: None,
|
||||
upgrade: Packages(
|
||||
{
|
||||
@@ -10792,7 +10793,7 @@ fn build_isolation_override() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
@@ -10974,7 +10975,7 @@ fn build_isolation_override() -> anyhow::Result<()> {
|
||||
annotation_style: Split,
|
||||
link_mode: Clone,
|
||||
compile_bytecode: false,
|
||||
sources: Enabled,
|
||||
sources: None,
|
||||
hash_checking: Some(
|
||||
Verify,
|
||||
),
|
||||
|
||||
@@ -8845,6 +8845,56 @@ fn sync_no_sources_missing_member() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Test `--no-sources-package` with sync to selectively disable sources.
|
||||
#[test]
|
||||
#[cfg(feature = "git")]
|
||||
fn sync_no_sources_package() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(
|
||||
r#"
|
||||
[project]
|
||||
name = "project"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = ["anyio", "iniconfig"]
|
||||
|
||||
[tool.uv.sources]
|
||||
anyio = { git = "https://github.com/agronholm/anyio", tag = "3.7.0" }
|
||||
iniconfig = { git = "https://github.com/pytest-dev/iniconfig", tag = "v2.0.0" }
|
||||
"#,
|
||||
)?;
|
||||
|
||||
// First lock the project
|
||||
uv_snapshot!(context.filters(), context.lock(), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
");
|
||||
|
||||
// Sync with sources disabled for anyio only
|
||||
uv_snapshot!(context.filters(), context.sync().arg("--no-sources-package").arg("anyio"), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 5 packages in [TIME]
|
||||
Prepared 4 packages in [TIME]
|
||||
Installed 4 packages in [TIME]
|
||||
+ anyio==3.7.0
|
||||
+ idna==3.6
|
||||
+ iniconfig==2.0.0 (from git+https://github.com/pytest-dev/iniconfig@93f5930e668c0d1ddf4597e38dd0dea4e2665e7a)
|
||||
+ sniffio==1.3.1
|
||||
");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sync_python_version() -> Result<()> {
|
||||
let context: TestContext = TestContext::new_with_versions(&["3.10", "3.11", "3.12"]);
|
||||
|
||||
Generated
+14
@@ -377,6 +377,13 @@
|
||||
"description": "Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the\nstandards-compliant, publishable package metadata, as opposed to using any local or Git\nsources.",
|
||||
"type": ["boolean", "null"]
|
||||
},
|
||||
"no-sources-package": {
|
||||
"description": "Ignore `tool.uv.sources` for the specified packages.",
|
||||
"type": ["array", "null"],
|
||||
"items": {
|
||||
"$ref": "#/definitions/PackageName"
|
||||
}
|
||||
},
|
||||
"offline": {
|
||||
"description": "Disable network access, relying only on locally cached data and locally available files.",
|
||||
"type": ["boolean", "null"]
|
||||
@@ -1408,6 +1415,13 @@
|
||||
"description": "Ignore the `tool.uv.sources` table when resolving dependencies. Used to lock against the\nstandards-compliant, publishable package metadata, as opposed to using any local or Git\nsources.",
|
||||
"type": ["boolean", "null"]
|
||||
},
|
||||
"no-sources-package": {
|
||||
"description": "Ignore `tool.uv.sources` for the specified packages.",
|
||||
"type": ["array", "null"],
|
||||
"items": {
|
||||
"$ref": "#/definitions/PackageName"
|
||||
}
|
||||
},
|
||||
"no-strip-extras": {
|
||||
"description": "Include extras in the output file.\n\nBy default, uv strips extras, as any packages pulled in by the extras are already included\nas dependencies in the output file directly. Further, output files generated with\n`--no-strip-extras` cannot be used as constraints files in `install` and `sync` invocations.",
|
||||
"type": ["boolean", "null"]
|
||||
|
||||
Reference in New Issue
Block a user