Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4161,7 +4161,7 @@ pub struct AddArgs {
pub branch: Option<String>,

/// Whether to use Git LFS when adding a dependency from Git.
#[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
#[arg(long)]
pub lfs: bool,

/// Extras to enable for the dependency.
Expand Down Expand Up @@ -5139,7 +5139,7 @@ pub struct ToolRunArgs {
pub refresh: RefreshArgs,

/// Whether to use Git LFS when adding a dependency from Git.
#[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
#[arg(long)]
pub lfs: bool,

/// The Python interpreter to use to build the run environment.
Expand Down Expand Up @@ -5290,7 +5290,7 @@ pub struct ToolInstallArgs {
pub force: bool,

/// Whether to use Git LFS when adding a dependency from Git.
#[arg(long, env = EnvVars::UV_GIT_LFS, value_parser = clap::builder::BoolishValueParser::new())]
#[arg(long)]
pub lfs: bool,

/// The Python interpreter to use to build the tool environment.
Expand Down
29 changes: 29 additions & 0 deletions crates/uv-configuration/src/vcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,32 @@ wheels/
# Virtual environments
.venv
";

/// Setting for Git LFS (Large File Storage) support.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum GitLfsSetting {
/// Git LFS is disabled (default).
#[default]
Disabled,
/// Git LFS is enabled. Tracks whether it came from an environment variable.
Enabled { from_env: bool },
}

impl GitLfsSetting {
pub fn new(from_arg: Option<bool>, from_env: Option<bool>) -> Self {
match (from_arg, from_env) {
(Some(true), _) => Self::Enabled { from_env: false },
(_, Some(true)) => Self::Enabled { from_env: true },
_ => Self::Disabled,
}
}
}

impl From<GitLfsSetting> for Option<bool> {
fn from(setting: GitLfsSetting) -> Self {
match setting {
GitLfsSetting::Enabled { .. } => Some(true),
GitLfsSetting::Disabled => None,
}
}
}
2 changes: 2 additions & 0 deletions crates/uv-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ pub struct EnvironmentOptions {
pub python_install_registry: Option<bool>,
pub install_mirrors: PythonInstallMirrors,
pub log_context: Option<bool>,
pub lfs: Option<bool>,
pub http_timeout: Duration,
pub http_retries: u32,
pub upload_http_timeout: Duration,
Expand Down Expand Up @@ -636,6 +637,7 @@ impl EnvironmentOptions {
)?,
},
log_context: parse_boolish_environment_variable(EnvVars::UV_LOG_CONTEXT)?,
lfs: parse_boolish_environment_variable(EnvVars::UV_GIT_LFS)?,
upload_http_timeout: parse_integer_environment_variable(
EnvVars::UV_UPLOAD_HTTP_TIMEOUT,
)?
Expand Down
16 changes: 10 additions & 6 deletions crates/uv-workspace/src/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use thiserror::Error;

use uv_build_backend::BuildBackendSettings;
use uv_configuration::GitLfsSetting;
use uv_distribution_types::{Index, IndexName, RequirementSource};
use uv_fs::{PortablePathBuf, relative_to};
use uv_git_types::GitReference;
Expand Down Expand Up @@ -1613,13 +1614,16 @@ impl Source {
rev: Option<String>,
tag: Option<String>,
branch: Option<String>,
lfs: Option<bool>,
lfs: GitLfsSetting,
root: &Path,
existing_sources: Option<&BTreeMap<PackageName, Sources>>,
) -> Result<Option<Self>, SourceError> {
// If the user specified a Git reference for a non-Git source, try existing Git sources before erroring.
if !matches!(source, RequirementSource::Git { .. })
&& (branch.is_some() || tag.is_some() || rev.is_some() || lfs.is_some())
&& (branch.is_some()
|| tag.is_some()
|| rev.is_some()
|| matches!(lfs, GitLfsSetting::Enabled { .. }))
{
if let Some(sources) = existing_sources {
if let Some(package_sources) = sources.get(name) {
Expand All @@ -1639,7 +1643,7 @@ impl Source {
rev,
tag,
branch,
lfs,
lfs: lfs.into(),
marker: *marker,
extra: extra.clone(),
group: group.clone(),
Expand All @@ -1657,7 +1661,7 @@ impl Source {
if let Some(branch) = branch {
return Err(SourceError::UnusedBranch(name.to_string(), branch));
}
if let Some(true) = lfs {
if matches!(lfs, GitLfsSetting::Enabled { from_env: false }) {
return Err(SourceError::UnusedLfs(name.to_string()));
}
}
Expand Down Expand Up @@ -1768,7 +1772,7 @@ impl Source {
rev: rev.cloned(),
tag,
branch,
lfs,
lfs: lfs.into(),
git: git.repository().clone(),
subdirectory: subdirectory.map(PortablePathBuf::from),
marker: MarkerTree::TRUE,
Expand All @@ -1780,7 +1784,7 @@ impl Source {
rev,
tag,
branch,
lfs,
lfs: lfs.into(),
git: git.repository().clone(),
subdirectory: subdirectory.map(PortablePathBuf::from),
marker: MarkerTree::TRUE,
Expand Down
11 changes: 6 additions & 5 deletions crates/uv/src/commands/project/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use uv_cache_key::RepositoryUrl;
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{
Concurrency, Constraints, DependencyGroups, DependencyGroupsWithDefaults, DevMode, DryRun,
ExtrasSpecification, ExtrasSpecificationWithDefaults, InstallOptions, SourceStrategy,
ExtrasSpecification, ExtrasSpecificationWithDefaults, GitLfsSetting, InstallOptions,
SourceStrategy,
};
use uv_dispatch::BuildDispatch;
use uv_distribution::{DistributionDatabase, LoweredExtraBuildDependencies};
Expand Down Expand Up @@ -85,7 +86,7 @@ pub(crate) async fn add(
rev: Option<String>,
tag: Option<String>,
branch: Option<String>,
lfs: Option<bool>,
lfs: GitLfsSetting,
extras_of_dependency: Vec<ExtraName>,
package: Option<PackageName>,
python: Option<String>,
Expand Down Expand Up @@ -377,7 +378,7 @@ pub(crate) async fn add(
rev.as_deref(),
tag.as_deref(),
branch.as_deref(),
lfs,
lfs.into(),
marker,
)
})
Expand Down Expand Up @@ -797,7 +798,7 @@ fn edits(
rev: Option<&str>,
tag: Option<&str>,
branch: Option<&str>,
lfs: Option<bool>,
lfs: GitLfsSetting,
extras: &[ExtraName],
index: Option<&IndexName>,
toml: &mut PyProjectTomlMut,
Expand Down Expand Up @@ -1231,7 +1232,7 @@ fn resolve_requirement(
rev: Option<String>,
tag: Option<String>,
branch: Option<String>,
lfs: Option<bool>,
lfs: GitLfsSetting,
root: &Path,
existing_sources: Option<&BTreeMap<PackageName, Sources>>,
) -> Result<(uv_pep508::Requirement, Option<Source>), anyhow::Error> {
Expand Down
11 changes: 5 additions & 6 deletions crates/uv/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use uv_cache::{Cache, CacheBucket};
use uv_cache_key::cache_digest;
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{
Concurrency, Constraints, DependencyGroupsWithDefaults, DryRun, ExtrasSpecification, Reinstall,
TargetTriple, Upgrade,
Concurrency, Constraints, DependencyGroupsWithDefaults, DryRun, ExtrasSpecification,
GitLfsSetting, Reinstall, TargetTriple, Upgrade,
};
use uv_dispatch::{BuildDispatch, SharedState};
use uv_distribution::{DistributionDatabase, LoweredExtraBuildDependencies, LoweredRequirement};
Expand Down Expand Up @@ -47,8 +47,7 @@ use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy};
use uv_virtualenv::remove_virtualenv;
use uv_warnings::{warn_user, warn_user_once};
use uv_workspace::dependency_groups::DependencyGroupError;
use uv_workspace::pyproject::ExtraBuildDependency;
use uv_workspace::pyproject::PyProjectToml;
use uv_workspace::pyproject::{ExtraBuildDependency, PyProjectToml};
use uv_workspace::{RequiresPythonSources, Workspace, WorkspaceCache};

use crate::commands::pip::loggers::{InstallLogger, ResolveLogger};
Expand Down Expand Up @@ -1685,14 +1684,14 @@ pub(crate) async fn resolve_names(
workspace_cache: &WorkspaceCache,
printer: Printer,
preview: Preview,
lfs: Option<bool>,
lfs: GitLfsSetting,
) -> Result<Vec<Requirement>, uv_requirements::Error> {
// Partition the requirements into named and unnamed requirements.
let (mut requirements, unnamed): (Vec<_>, Vec<_>) = requirements
.into_iter()
.map(|spec| {
spec.requirement
.augment_requirement(None, None, None, lfs, None)
.augment_requirement(None, None, None, lfs.into(), None)
})
.partition_map(|requirement| match requirement {
UnresolvedRequirement::Named(requirement) => itertools::Either::Left(requirement),
Expand Down
6 changes: 4 additions & 2 deletions crates/uv/src/commands/tool/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use tracing::{debug, trace};
use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp;
use uv_client::{BaseClientBuilder, RegistryClientBuilder};
use uv_configuration::{Concurrency, Constraints, DryRun, Reinstall, TargetTriple, Upgrade};
use uv_configuration::{
Concurrency, Constraints, DryRun, GitLfsSetting, Reinstall, TargetTriple, Upgrade,
};
use uv_distribution::LoweredExtraBuildDependencies;
use uv_distribution_types::{
ExtraBuildRequires, IndexCapabilities, NameRequirementSpecification, Requirement,
Expand Down Expand Up @@ -58,7 +60,7 @@ pub(crate) async fn install(
excludes: &[RequirementsSource],
build_constraints: &[RequirementsSource],
entrypoints: &[PackageName],
lfs: Option<bool>,
lfs: GitLfsSetting,
python: Option<String>,
python_platform: Option<TargetTriple>,
install_mirrors: PythonInstallMirrors,
Expand Down
8 changes: 3 additions & 5 deletions crates/uv/src/commands/tool/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp;
use uv_cli::ExternalCommand;
use uv_client::{BaseClientBuilder, RegistryClientBuilder};
use uv_configuration::Concurrency;
use uv_configuration::Constraints;
use uv_configuration::TargetTriple;
use uv_configuration::{Concurrency, Constraints, GitLfsSetting, TargetTriple};
use uv_distribution::LoweredExtraBuildDependencies;
use uv_distribution_types::InstalledDist;
use uv_distribution_types::{
Expand Down Expand Up @@ -106,7 +104,7 @@ pub(crate) async fn run(
overrides: &[RequirementsSource],
build_constraints: &[RequirementsSource],
show_resolution: bool,
lfs: Option<bool>,
lfs: GitLfsSetting,
python: Option<String>,
python_platform: Option<TargetTriple>,
install_mirrors: PythonInstallMirrors,
Expand Down Expand Up @@ -726,7 +724,7 @@ async fn get_or_create_environment(
settings: &ResolverInstallerSettings,
client_builder: &BaseClientBuilder<'_>,
isolated: bool,
lfs: Option<bool>,
lfs: GitLfsSetting,
python_preference: PythonPreference,
python_downloads: PythonDownloads,
installer_metadata: bool,
Expand Down
20 changes: 10 additions & 10 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use uv_cli::{
use uv_client::Connectivity;
use uv_configuration::{
BuildIsolation, BuildOptions, Concurrency, DependencyGroups, DryRun, EditableMode, EnvFile,
ExportFormat, ExtrasSpecification, HashCheckingMode, IndexStrategy, InstallOptions,
KeyringProviderType, NoBinary, NoBuild, PipCompileFormat, ProjectBuildBackend, Reinstall,
RequiredVersion, SourceStrategy, TargetTriple, TrustedHost, TrustedPublishing, Upgrade,
VersionControlSystem,
ExportFormat, ExtrasSpecification, GitLfsSetting, HashCheckingMode, IndexStrategy,
InstallOptions, KeyringProviderType, NoBinary, NoBuild, PipCompileFormat, ProjectBuildBackend,
Reinstall, RequiredVersion, SourceStrategy, TargetTriple, TrustedHost, TrustedPublishing,
Upgrade, VersionControlSystem,
};
use uv_distribution_types::{
ConfigSettings, DependencyMetadata, ExtraBuildVariables, Index, IndexLocations, IndexUrl,
Expand Down Expand Up @@ -547,7 +547,7 @@ pub(crate) struct ToolRunSettings {
pub(crate) build_constraints: Vec<PathBuf>,
pub(crate) isolated: bool,
pub(crate) show_resolution: bool,
pub(crate) lfs: Option<bool>,
pub(crate) lfs: GitLfsSetting,
pub(crate) python: Option<String>,
pub(crate) python_platform: Option<TargetTriple>,
pub(crate) install_mirrors: PythonInstallMirrors,
Expand Down Expand Up @@ -630,7 +630,7 @@ impl ToolRunSettings {
.unwrap_or_default();

let settings = ResolverInstallerSettings::from(options.clone());
let lfs = lfs.then_some(true);
let lfs = GitLfsSetting::new(lfs.then_some(true), environment.lfs);

Self {
command,
Expand Down Expand Up @@ -689,7 +689,7 @@ pub(crate) struct ToolInstallSettings {
pub(crate) overrides: Vec<PathBuf>,
pub(crate) excludes: Vec<PathBuf>,
pub(crate) build_constraints: Vec<PathBuf>,
pub(crate) lfs: Option<bool>,
pub(crate) lfs: GitLfsSetting,
pub(crate) python: Option<String>,
pub(crate) python_platform: Option<TargetTriple>,
pub(crate) refresh: Refresh,
Expand Down Expand Up @@ -744,7 +744,7 @@ impl ToolInstallSettings {
.unwrap_or_default();

let settings = ResolverInstallerSettings::from(options.clone());
let lfs = lfs.then_some(true);
let lfs = GitLfsSetting::new(lfs.then_some(true), environment.lfs);

Self {
package,
Expand Down Expand Up @@ -1570,7 +1570,7 @@ pub(crate) struct AddSettings {
pub(crate) rev: Option<String>,
pub(crate) tag: Option<String>,
pub(crate) branch: Option<String>,
pub(crate) lfs: Option<bool>,
pub(crate) lfs: GitLfsSetting,
pub(crate) package: Option<PackageName>,
pub(crate) script: Option<PathBuf>,
pub(crate) python: Option<String>,
Expand Down Expand Up @@ -1713,7 +1713,7 @@ impl AddSettings {
.unwrap_or_default();

let bounds = bounds.or(filesystem.as_ref().and_then(|fs| fs.add.add_bounds));
let lfs = lfs.then_some(true);
let lfs = GitLfsSetting::new(lfs.then_some(true), environment.lfs);

Self {
lock_check: if locked {
Expand Down
Loading
Loading