Use link mode for builds, in uv pip compile and for uv venv seed packages (#3016)

Use the user specified link mode for temporary build venvs, too. It
seems consistent to respect the user's link mode for all installations
we perform
This commit is contained in:
konsti 2024-04-15 10:49:41 +02:00 committed by GitHub
parent aa855ee729
commit eded6c9fae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 43 additions and 1 deletions

2
Cargo.lock generated
View file

@ -4507,6 +4507,7 @@ dependencies = [
"fs-err", "fs-err",
"futures", "futures",
"indicatif", "indicatif",
"install-wheel-rs",
"itertools 0.12.1", "itertools 0.12.1",
"mimalloc", "mimalloc",
"owo-colors", "owo-colors",
@ -4547,6 +4548,7 @@ dependencies = [
"anyhow", "anyhow",
"distribution-types", "distribution-types",
"futures", "futures",
"install-wheel-rs",
"itertools 0.12.1", "itertools 0.12.1",
"pep508_rs", "pep508_rs",
"rustc-hash", "rustc-hash",

View file

@ -18,6 +18,7 @@ workspace = true
[dependencies] [dependencies]
distribution-filename = { workspace = true } distribution-filename = { workspace = true }
distribution-types = { workspace = true } distribution-types = { workspace = true }
install-wheel-rs = { workspace = true }
pep440_rs = { workspace = true } pep440_rs = { workspace = true }
pep508_rs = { workspace = true } pep508_rs = { workspace = true }
uv-build = { workspace = true } uv-build = { workspace = true }

View file

@ -73,6 +73,7 @@ pub(crate) async fn build(args: BuildArgs) -> Result<PathBuf> {
setup_py, setup_py,
&config_settings, &config_settings,
BuildIsolation::Isolated, BuildIsolation::Isolated,
install_wheel_rs::linker::LinkMode::default(),
&NoBuild::None, &NoBuild::None,
&NoBinary::None, &NoBinary::None,
); );

View file

@ -91,6 +91,7 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
SetupPyStrategy::default(), SetupPyStrategy::default(),
&config_settings, &config_settings,
BuildIsolation::Isolated, BuildIsolation::Isolated,
install_wheel_rs::linker::LinkMode::default(),
&no_build, &no_build,
&NoBinary::None, &NoBinary::None,
); );

View file

@ -115,6 +115,7 @@ pub(crate) async fn resolve_many(args: ResolveManyArgs) -> Result<()> {
setup_py, setup_py,
&config_settings, &config_settings,
BuildIsolation::Isolated, BuildIsolation::Isolated,
install_wheel_rs::linker::LinkMode::default(),
&no_build, &no_build,
&NoBinary::None, &NoBinary::None,
); );

View file

@ -15,15 +15,16 @@ workspace = true
[dependencies] [dependencies]
distribution-types = { workspace = true } distribution-types = { workspace = true }
install-wheel-rs = { workspace = true }
pep508_rs = { workspace = true } pep508_rs = { workspace = true }
uv-build = { workspace = true } uv-build = { workspace = true }
uv-cache = { workspace = true } uv-cache = { workspace = true }
uv-client = { workspace = true } uv-client = { workspace = true }
uv-configuration = { workspace = true }
uv-installer = { workspace = true } uv-installer = { workspace = true }
uv-interpreter = { workspace = true } uv-interpreter = { workspace = true }
uv-resolver = { workspace = true } uv-resolver = { workspace = true }
uv-types = { workspace = true } uv-types = { workspace = true }
uv-configuration = { workspace = true }
anyhow = { workspace = true } anyhow = { workspace = true }
futures = { workspace = true } futures = { workspace = true }

View file

@ -35,6 +35,7 @@ pub struct BuildDispatch<'a> {
in_flight: &'a InFlight, in_flight: &'a InFlight,
setup_py: SetupPyStrategy, setup_py: SetupPyStrategy,
build_isolation: BuildIsolation<'a>, build_isolation: BuildIsolation<'a>,
link_mode: install_wheel_rs::linker::LinkMode,
no_build: &'a NoBuild, no_build: &'a NoBuild,
no_binary: &'a NoBinary, no_binary: &'a NoBinary,
config_settings: &'a ConfigSettings, config_settings: &'a ConfigSettings,
@ -56,6 +57,7 @@ impl<'a> BuildDispatch<'a> {
setup_py: SetupPyStrategy, setup_py: SetupPyStrategy,
config_settings: &'a ConfigSettings, config_settings: &'a ConfigSettings,
build_isolation: BuildIsolation<'a>, build_isolation: BuildIsolation<'a>,
link_mode: install_wheel_rs::linker::LinkMode,
no_build: &'a NoBuild, no_build: &'a NoBuild,
no_binary: &'a NoBinary, no_binary: &'a NoBinary,
) -> Self { ) -> Self {
@ -70,6 +72,7 @@ impl<'a> BuildDispatch<'a> {
setup_py, setup_py,
config_settings, config_settings,
build_isolation, build_isolation,
link_mode,
no_build, no_build,
no_binary, no_binary,
source_build_context: SourceBuildContext::default(), source_build_context: SourceBuildContext::default(),
@ -262,6 +265,7 @@ impl<'a> BuildContext for BuildDispatch<'a> {
wheels.iter().map(ToString::to_string).join(", ") wheels.iter().map(ToString::to_string).join(", ")
); );
Installer::new(venv) Installer::new(venv)
.with_link_mode(self.link_mode)
.install(&wheels) .install(&wheels)
.context("Failed to install build dependencies")?; .context("Failed to install build dependencies")?;
} }

View file

@ -323,6 +323,15 @@ pub(crate) struct PipCompileArgs {
#[clap(long)] #[clap(long)]
pub(crate) refresh_package: Vec<PackageName>, pub(crate) refresh_package: Vec<PackageName>,
/// The method to use when installing packages from the global cache.
///
/// This option is only used when creating build environments for source distributions.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
#[clap(long, value_enum, default_value_t = install_wheel_rs::linker::LinkMode::default())]
pub(crate) link_mode: install_wheel_rs::linker::LinkMode,
/// The URL of the Python package index (by default: <https://pypi.org/simple>). /// The URL of the Python package index (by default: <https://pypi.org/simple>).
/// ///
/// The index given by this flag is given lower priority than all other /// The index given by this flag is given lower priority than all other
@ -1239,6 +1248,15 @@ pub(crate) struct VenvArgs {
#[clap(long)] #[clap(long)]
pub(crate) system_site_packages: bool, pub(crate) system_site_packages: bool,
/// The method to use when installing packages from the global cache.
///
/// This option is only used for installing seed packages.
///
/// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and
/// Windows.
#[clap(long, value_enum, default_value_t = install_wheel_rs::linker::LinkMode::default())]
pub(crate) link_mode: install_wheel_rs::linker::LinkMode,
/// The URL of the Python package index (by default: <https://pypi.org/simple>). /// The URL of the Python package index (by default: <https://pypi.org/simple>).
/// ///
/// The index given by this flag is given lower priority than all other /// The index given by this flag is given lower priority than all other

View file

@ -15,6 +15,7 @@ use tempfile::tempdir_in;
use tracing::debug; use tracing::debug;
use distribution_types::{IndexLocations, LocalEditable, LocalEditables, Verbatim}; use distribution_types::{IndexLocations, LocalEditable, LocalEditables, Verbatim};
use install_wheel_rs::linker::LinkMode;
use platform_tags::Tags; use platform_tags::Tags;
use requirements_txt::EditableRequirement; use requirements_txt::EditableRequirement;
use uv_auth::{KeyringProvider, GLOBAL_AUTH_STORE}; use uv_auth::{KeyringProvider, GLOBAL_AUTH_STORE};
@ -80,6 +81,7 @@ pub(crate) async fn pip_compile(
annotation_style: AnnotationStyle, annotation_style: AnnotationStyle,
native_tls: bool, native_tls: bool,
quiet: bool, quiet: bool,
link_mode: LinkMode,
cache: Cache, cache: Cache,
printer: Printer, printer: Printer,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
@ -262,6 +264,7 @@ pub(crate) async fn pip_compile(
setup_py, setup_py,
&config_settings, &config_settings,
build_isolation, build_isolation,
link_mode,
&no_build, &no_build,
&NoBinary::None, &NoBinary::None,
) )

View file

@ -255,6 +255,7 @@ pub(crate) async fn pip_install(
setup_py, setup_py,
config_settings, config_settings,
build_isolation, build_isolation,
link_mode,
&no_build, &no_build,
&no_binary, &no_binary,
) )
@ -382,6 +383,7 @@ pub(crate) async fn pip_install(
setup_py, setup_py,
config_settings, config_settings,
build_isolation, build_isolation,
link_mode,
&no_build, &no_build,
&no_binary, &no_binary,
) )

View file

@ -205,6 +205,7 @@ pub(crate) async fn pip_sync(
setup_py, setup_py,
config_settings, config_settings,
build_isolation, build_isolation,
link_mode,
&no_build, &no_build,
&no_binary, &no_binary,
); );

View file

@ -12,6 +12,7 @@ use owo_colors::OwoColorize;
use thiserror::Error; use thiserror::Error;
use distribution_types::{DistributionMetadata, IndexLocations, Name, ResolvedDist}; use distribution_types::{DistributionMetadata, IndexLocations, Name, ResolvedDist};
use install_wheel_rs::linker::LinkMode;
use pep508_rs::Requirement; use pep508_rs::Requirement;
use uv_auth::{KeyringProvider, GLOBAL_AUTH_STORE}; use uv_auth::{KeyringProvider, GLOBAL_AUTH_STORE};
use uv_cache::Cache; use uv_cache::Cache;
@ -32,6 +33,7 @@ use crate::shell::Shell;
pub(crate) async fn venv( pub(crate) async fn venv(
path: &Path, path: &Path,
python_request: Option<&str>, python_request: Option<&str>,
link_mode: LinkMode,
index_locations: &IndexLocations, index_locations: &IndexLocations,
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
keyring_provider: KeyringProvider, keyring_provider: KeyringProvider,
@ -47,6 +49,7 @@ pub(crate) async fn venv(
match venv_impl( match venv_impl(
path, path,
python_request, python_request,
link_mode,
index_locations, index_locations,
index_strategy, index_strategy,
keyring_provider, keyring_provider,
@ -93,6 +96,7 @@ enum VenvError {
async fn venv_impl( async fn venv_impl(
path: &Path, path: &Path,
python_request: Option<&str>, python_request: Option<&str>,
link_mode: LinkMode,
index_locations: &IndexLocations, index_locations: &IndexLocations,
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
keyring_provider: KeyringProvider, keyring_provider: KeyringProvider,
@ -197,6 +201,7 @@ async fn venv_impl(
SetupPyStrategy::default(), SetupPyStrategy::default(),
&config_settings, &config_settings,
BuildIsolation::Isolated, BuildIsolation::Isolated,
link_mode,
&NoBuild::All, &NoBuild::All,
&NoBinary::None, &NoBinary::None,
) )

View file

@ -245,6 +245,7 @@ async fn run() -> Result<ExitStatus> {
args.annotation_style, args.annotation_style,
cli.native_tls, cli.native_tls,
cli.quiet, cli.quiet,
args.link_mode,
cache, cache,
printer, printer,
) )
@ -514,6 +515,7 @@ async fn run() -> Result<ExitStatus> {
commands::venv( commands::venv(
&args.name, &args.name,
args.python.as_deref(), args.python.as_deref(),
args.link_mode,
&index_locations, &index_locations,
args.index_strategy, args.index_strategy,
args.keyring_provider, args.keyring_provider,