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",
"futures",
"indicatif",
"install-wheel-rs",
"itertools 0.12.1",
"mimalloc",
"owo-colors",
@ -4547,6 +4548,7 @@ dependencies = [
"anyhow",
"distribution-types",
"futures",
"install-wheel-rs",
"itertools 0.12.1",
"pep508_rs",
"rustc-hash",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -323,6 +323,15 @@ pub(crate) struct PipCompileArgs {
#[clap(long)]
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 index given by this flag is given lower priority than all other
@ -1239,6 +1248,15 @@ pub(crate) struct VenvArgs {
#[clap(long)]
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 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 distribution_types::{IndexLocations, LocalEditable, LocalEditables, Verbatim};
use install_wheel_rs::linker::LinkMode;
use platform_tags::Tags;
use requirements_txt::EditableRequirement;
use uv_auth::{KeyringProvider, GLOBAL_AUTH_STORE};
@ -80,6 +81,7 @@ pub(crate) async fn pip_compile(
annotation_style: AnnotationStyle,
native_tls: bool,
quiet: bool,
link_mode: LinkMode,
cache: Cache,
printer: Printer,
) -> Result<ExitStatus> {
@ -262,6 +264,7 @@ pub(crate) async fn pip_compile(
setup_py,
&config_settings,
build_isolation,
link_mode,
&no_build,
&NoBinary::None,
)

View file

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

View file

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

View file

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

View file

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