From 152f167cccd6cee6d0f1751ed776903b0df401f2 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 19 Aug 2024 16:57:59 -0400 Subject: [PATCH] Remove `--legacy-setup-py` command-line argument (#4255) This is a fallback mode that we supported when we decided to use PEP 517 builds by default. I can't find a single reference to it on GitHub or in our issue tracker, so I want to drop support for it as part of v0.3.0. --- crates/bench/benches/uv.rs | 3 +- crates/uv-build/src/lib.rs | 173 ++++--------------- crates/uv-cli/src/lib.rs | 24 --- crates/uv-configuration/src/build_options.rs | 10 -- crates/uv-dev/src/build.rs | 6 +- crates/uv-dispatch/src/lib.rs | 7 +- crates/uv-settings/src/settings.rs | 10 -- crates/uv/src/commands/pip/compile.rs | 4 +- crates/uv/src/commands/pip/install.rs | 4 +- crates/uv/src/commands/pip/sync.rs | 4 +- crates/uv/src/commands/project/add.rs | 4 +- crates/uv/src/commands/project/lock.rs | 4 +- crates/uv/src/commands/project/mod.rs | 10 +- crates/uv/src/commands/project/sync.rs | 4 +- crates/uv/src/commands/venv.rs | 4 +- crates/uv/src/lib.rs | 3 - crates/uv/src/settings.rs | 24 +-- crates/uv/tests/pip_compile.rs | 34 +--- crates/uv/tests/pip_sync.rs | 28 +-- crates/uv/tests/show_settings.rs | 21 --- docs/reference/cli.md | 6 - docs/reference/settings.md | 27 --- uv.schema.json | 7 - 23 files changed, 53 insertions(+), 368 deletions(-) diff --git a/crates/bench/benches/uv.rs b/crates/bench/benches/uv.rs index 7f875a619119..ac51efcc7388 100644 --- a/crates/bench/benches/uv.rs +++ b/crates/bench/benches/uv.rs @@ -91,7 +91,7 @@ mod resolver { use uv_cache::Cache; use uv_client::RegistryClient; use uv_configuration::{ - BuildOptions, Concurrency, ConfigSettings, IndexStrategy, SetupPyStrategy, SourceStrategy, + BuildOptions, Concurrency, ConfigSettings, IndexStrategy, SourceStrategy, }; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; @@ -179,7 +179,6 @@ mod resolver { &git, &in_flight, IndexStrategy::default(), - SetupPyStrategy::default(), &config_settings, build_isolation, LinkMode::default(), diff --git a/crates/uv-build/src/lib.rs b/crates/uv-build/src/lib.rs index 03a08dbb5ad4..3c0f1b469a4b 100644 --- a/crates/uv-build/src/lib.rs +++ b/crates/uv-build/src/lib.rs @@ -28,7 +28,7 @@ use distribution_types::Resolution; use pep440_rs::Version; use pep508_rs::PackageName; use pypi_types::{Requirement, VerbatimParsedUrl}; -use uv_configuration::{BuildKind, ConfigSettings, SetupPyStrategy}; +use uv_configuration::{BuildKind, ConfigSettings}; use uv_fs::{rename_with_retry, PythonExt, Simplified}; use uv_python::{Interpreter, PythonEnvironment}; use uv_types::{BuildContext, BuildIsolation, SourceBuildTrait}; @@ -75,14 +75,6 @@ static DEFAULT_BACKEND: LazyLock = LazyLock::new(|| Pep517Backend )], }); -/// The requirements for `--legacy-setup-py` builds. -static SETUP_PY_REQUIREMENTS: LazyLock<[Requirement; 2]> = LazyLock::new(|| { - [ - Requirement::from(pep508_rs::Requirement::from_str("setuptools >= 40.8.0").unwrap()), - Requirement::from(pep508_rs::Requirement::from_str("wheel").unwrap()), - ] -}); - #[derive(Error, Debug)] pub enum Error { #[error(transparent)] @@ -359,8 +351,6 @@ impl Pep517Backend { pub struct SourceBuildContext { /// An in-memory resolution of the default backend's requirements for PEP 517 builds. default_resolution: Rc>>, - /// An in-memory resolution of the build requirements for `--legacy-setup-py` builds. - setup_py_resolution: Rc>>, } /// Holds the state through a series of PEP 517 frontend to backend calls or a single setup.py @@ -373,7 +363,7 @@ pub struct SourceBuild { source_tree: PathBuf, config_settings: ConfigSettings, /// If performing a PEP 517 build, the backend to use. - pep517_backend: Option, + pep517_backend: Pep517Backend, /// The PEP 621 project metadata, if any. project: Option, /// The virtual environment in which to build the source distribution. @@ -412,7 +402,6 @@ impl SourceBuild { build_context: &impl BuildContext, source_build_context: SourceBuildContext, version_id: String, - setup_py: SetupPyStrategy, config_settings: ConfigSettings, build_isolation: BuildIsolation<'_>, build_kind: BuildKind, @@ -431,8 +420,7 @@ impl SourceBuild { // Check if we have a PEP 517 build backend. let (pep517_backend, project) = - Self::extract_pep517_backend(&source_tree, setup_py, &default_backend) - .map_err(|err| *err)?; + Self::extract_pep517_backend(&source_tree, &default_backend).map_err(|err| *err)?; let package_name = project.clone().map(|p| p.name); @@ -457,7 +445,7 @@ impl SourceBuild { build_context, source_build_context, &default_backend, - pep517_backend.as_ref(), + &pep517_backend, ) .await?; @@ -503,22 +491,20 @@ impl SourceBuild { // environment is already setup. let runner = PythonRunner::new(concurrent_builds); if build_isolation.is_isolated(package_name.as_ref()) { - if let Some(pep517_backend) = &pep517_backend { - create_pep517_build_environment( - &runner, - &source_tree, - &venv, - pep517_backend, - build_context, - &version_id, - build_kind, - &config_settings, - &environment_variables, - &modified_path, - &temp_dir, - ) - .await?; - } + create_pep517_build_environment( + &runner, + &source_tree, + &venv, + &pep517_backend, + build_context, + &version_id, + build_kind, + &config_settings, + &environment_variables, + &modified_path, + &temp_dir, + ) + .await?; } Ok(Self { @@ -541,9 +527,9 @@ impl SourceBuild { build_context: &impl BuildContext, source_build_context: SourceBuildContext, default_backend: &Pep517Backend, - pep517_backend: Option<&Pep517Backend>, + pep517_backend: &Pep517Backend, ) -> Result { - Ok(if let Some(pep517_backend) = pep517_backend { + Ok( if pep517_backend.requirements == default_backend.requirements { let mut resolution = source_build_context.default_resolution.lock().await; if let Some(resolved_requirements) = &*resolution { @@ -565,29 +551,15 @@ impl SourceBuild { .map_err(|err| { Error::RequirementsInstall("build-system.requires (resolve)", err) })? - } - } else { - // Install default requirements for `setup.py`-based builds. - let mut resolution = source_build_context.setup_py_resolution.lock().await; - if let Some(resolved_requirements) = &*resolution { - resolved_requirements.clone() - } else { - let resolved_requirements = build_context - .resolve(&*SETUP_PY_REQUIREMENTS) - .await - .map_err(|err| Error::RequirementsInstall("setup.py build (resolve)", err))?; - *resolution = Some(resolved_requirements.clone()); - resolved_requirements - } - }) + }, + ) } /// Extract the PEP 517 backend from the `pyproject.toml` or `setup.py` file. fn extract_pep517_backend( source_tree: &Path, - setup_py: SetupPyStrategy, default_backend: &Pep517Backend, - ) -> Result<(Option, Option), Box> { + ) -> Result<(Pep517Backend, Option), Box> { match fs::read_to_string(source_tree.join("pyproject.toml")) { Ok(toml) => { let pyproject_toml: PyProjectToml = @@ -616,7 +588,7 @@ impl SourceBuild { // a PEP 517 build using the default backend, to match `pip` and `build`. default_backend.clone() }; - Ok((Some(backend), pyproject_toml.project)) + Ok((backend, pyproject_toml.project)) } Err(err) if err.kind() == io::ErrorKind::NotFound => { // We require either a `pyproject.toml` or a `setup.py` file at the top level. @@ -629,13 +601,9 @@ impl SourceBuild { // If no `pyproject.toml` is present, by default, proceed with a PEP 517 build using // the default backend, to match `build`. `pip` uses `setup.py` directly in this - // case (which we allow via `SetupPyStrategy::Setuptools`), but plans to make PEP - // 517 builds the default in the future. + // case, but plans to make PEP 517 builds the default in the future. // See: https://github.com/pypa/pip/issues/9175. - match setup_py { - SetupPyStrategy::Pep517 => Ok((Some(default_backend.clone()), None)), - SetupPyStrategy::Setuptools => Ok((None, None)), - } + Ok((default_backend.clone(), None)) } Err(err) => Err(Box::new(err.into())), } @@ -644,10 +612,6 @@ impl SourceBuild { /// Try calling `prepare_metadata_for_build_wheel` to get the metadata without executing the /// actual build. pub async fn get_metadata_without_build(&mut self) -> Result, Error> { - let Some(pep517_backend) = &self.pep517_backend else { - return Ok(None); - }; - // We've already called this method; return the existing result. if let Some(metadata_dir) = &self.metadata_directory { return Ok(Some(metadata_dir.clone())); @@ -668,7 +632,7 @@ impl SourceBuild { // this is just an optimization. // // See: https://github.com/astral-sh/uv/issues/2130 - if pep517_backend.backend == "hatchling.build" { + if self.pep517_backend.backend == "hatchling.build" { if self .project .as_ref() @@ -694,7 +658,7 @@ impl SourceBuild { debug!( "Calling `{}.prepare_metadata_for_build_{}()`", - pep517_backend.backend, self.build_kind, + self.pep517_backend.backend, self.build_kind, ); let script = formatdoc! { r#" @@ -710,7 +674,7 @@ impl SourceBuild { with open("{}", "w") as fp: fp.write(dirname or "") "#, - pep517_backend.backend_import(), + self.pep517_backend.backend_import(), self.build_kind, escape_path_for_python(&metadata_directory), self.config_settings.escape_for_python(), @@ -760,55 +724,16 @@ impl SourceBuild { // The build scripts run with the extracted root as cwd, so they need the absolute path. let wheel_dir = fs::canonicalize(wheel_dir)?; - if let Some(pep517_backend) = &self.pep517_backend { - // Prevent clashes from two uv processes building wheels in parallel. - let tmp_dir = tempdir_in(&wheel_dir)?; - let filename = self.pep517_build(tmp_dir.path(), pep517_backend).await?; - - let from = tmp_dir.path().join(&filename); - let to = wheel_dir.join(&filename); - rename_with_retry(from, to).await?; - Ok(filename) - } else { - if self.build_kind != BuildKind::Wheel { - return Err(Error::EditableSetupPy); - } - // We checked earlier that setup.py exists. - let span = info_span!( - "run_python_script", - script="setup.py bdist_wheel", - python_version = %self.venv.interpreter().python_version() - ); - let output = self - .runner - .run_setup_py(&self.venv, "bdist_wheel", &self.source_tree) - .instrument(span) - .await?; - if !output.status.success() { - return Err(Error::from_command_output( - "Failed building wheel through setup.py".to_string(), - &output, - &self.version_id, - )); - } - let dist = fs::read_dir(self.source_tree.join("dist"))?; - let dist_dir = dist.collect::>>()?; - let [dist_wheel] = dist_dir.as_slice() else { - return Err(Error::from_command_output( - format!( - "Expected exactly wheel in `dist/` after invoking setup.py, found {dist_dir:?}" - ), - &output, - &self.version_id) - ); - }; - - let from = dist_wheel.path(); - let to = wheel_dir.join(dist_wheel.file_name()); - fs_err::copy(from, to)?; + // Prevent clashes from two uv processes building wheels in parallel. + let tmp_dir = tempdir_in(&wheel_dir)?; + let filename = self + .pep517_build(tmp_dir.path(), &self.pep517_backend) + .await?; - Ok(dist_wheel.file_name().to_string_lossy().to_string()) - } + let from = tmp_dir.path().join(&filename); + let to = wheel_dir.join(&filename); + rename_with_retry(from, to).await?; + Ok(filename) } async fn pep517_build( @@ -1072,28 +997,6 @@ impl PythonRunner { .await .map_err(|err| Error::CommandFailed(venv.python_executable().to_path_buf(), err)) } - - /// Spawn a process that runs a `setup.py` script. - /// - /// If the concurrency limit has been reached this method will wait until a pending - /// script completes before spawning this one. - /// - /// Note: It is the caller's responsibility to create an informative span. - async fn run_setup_py( - &self, - venv: &PythonEnvironment, - script: &str, - source_tree: &Path, - ) -> Result { - let _permit = self.control.acquire().await.unwrap(); - - Command::new(venv.python_executable()) - .args(["setup.py", script]) - .current_dir(source_tree.simplified()) - .output() - .await - .map_err(|err| Error::CommandFailed(venv.python_executable().to_path_buf(), err)) - } } #[cfg(test)] diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index fe047e78e14d..921f6d082f7c 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -869,14 +869,6 @@ pub struct PipCompileArgs { #[arg(long, overrides_with("generate_hashes"), hide = true)] pub no_generate_hashes: bool, - /// Use legacy `setuptools` behavior when building source distributions without a - /// `pyproject.toml`. - #[arg(long, overrides_with("no_legacy_setup_py"))] - pub legacy_setup_py: bool, - - #[arg(long, overrides_with("legacy_setup_py"), hide = true)] - pub no_legacy_setup_py: bool, - /// Don't build source distributions. /// /// When enabled, resolving will not run arbitrary Python code. The cached wheels of @@ -1159,14 +1151,6 @@ pub struct PipSyncArgs { #[arg(long, conflicts_with = "target")] pub prefix: Option, - /// Use legacy `setuptools` behavior when building source distributions without a - /// `pyproject.toml`. - #[arg(long, overrides_with("no_legacy_setup_py"))] - pub legacy_setup_py: bool, - - #[arg(long, overrides_with("legacy_setup_py"), hide = true)] - pub no_legacy_setup_py: bool, - /// Don't build source distributions. /// /// When enabled, resolving will not run arbitrary Python code. The cached wheels of @@ -1449,14 +1433,6 @@ pub struct PipInstallArgs { #[arg(long, conflicts_with = "target")] pub prefix: Option, - /// Use legacy `setuptools` behavior when building source distributions without a - /// `pyproject.toml`. - #[arg(long, overrides_with("no_legacy_setup_py"))] - pub legacy_setup_py: bool, - - #[arg(long, overrides_with("legacy_setup_py"), hide = true)] - pub no_legacy_setup_py: bool, - /// Don't build source distributions. /// /// When enabled, resolving will not run arbitrary Python code. The cached wheels of diff --git a/crates/uv-configuration/src/build_options.rs b/crates/uv-configuration/src/build_options.rs index 6a75f03f2138..ee7a0c5c1d05 100644 --- a/crates/uv-configuration/src/build_options.rs +++ b/crates/uv-configuration/src/build_options.rs @@ -4,16 +4,6 @@ use pep508_rs::PackageName; use crate::{PackageNameSpecifier, PackageNameSpecifiers}; -/// The strategy to use when building source distributions that lack a `pyproject.toml`. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -pub enum SetupPyStrategy { - /// Perform a PEP 517 build. - #[default] - Pep517, - /// Perform a build by invoking `setuptools` directly. - Setuptools, -} - #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub enum BuildKind { /// A regular PEP 517 wheel build diff --git a/crates/uv-dev/src/build.rs b/crates/uv-dev/src/build.rs index a292425b27bc..0b7a3584f7fb 100644 --- a/crates/uv-dev/src/build.rs +++ b/crates/uv-dev/src/build.rs @@ -11,8 +11,7 @@ use uv_build::{SourceBuild, SourceBuildContext}; use uv_cache::{Cache, CacheArgs}; use uv_client::RegistryClientBuilder; use uv_configuration::{ - BuildKind, BuildOptions, Concurrency, ConfigSettings, IndexStrategy, SetupPyStrategy, - SourceStrategy, + BuildKind, BuildOptions, Concurrency, ConfigSettings, IndexStrategy, SourceStrategy, }; use uv_dispatch::BuildDispatch; use uv_git::GitResolver; @@ -67,7 +66,6 @@ pub(crate) async fn build(args: BuildArgs) -> Result { let index = InMemoryIndex::default(); let index_urls = IndexLocations::default(); let index_strategy = IndexStrategy::default(); - let setup_py = SetupPyStrategy::default(); let sources = SourceStrategy::default(); let python = PythonEnvironment::find( &PythonRequest::default(), @@ -88,7 +86,6 @@ pub(crate) async fn build(args: BuildArgs) -> Result { &git, &in_flight, index_strategy, - setup_py, &config_settings, BuildIsolation::Isolated, install_wheel_rs::linker::LinkMode::default(), @@ -105,7 +102,6 @@ pub(crate) async fn build(args: BuildArgs) -> Result { &build_dispatch, SourceBuildContext::default(), args.sdist.display().to_string(), - setup_py, config_settings.clone(), BuildIsolation::Isolated, build_kind, diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index bc62ca4270fe..9b813452303c 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -18,8 +18,7 @@ use uv_cache::Cache; use uv_client::RegistryClient; use uv_configuration::Concurrency; use uv_configuration::{ - BuildKind, BuildOptions, ConfigSettings, Constraints, IndexStrategy, Reinstall, - SetupPyStrategy, SourceStrategy, + BuildKind, BuildOptions, ConfigSettings, Constraints, IndexStrategy, Reinstall, SourceStrategy, }; use uv_distribution::DistributionDatabase; use uv_git::GitResolver; @@ -44,7 +43,6 @@ pub struct BuildDispatch<'a> { index: &'a InMemoryIndex, git: &'a GitResolver, in_flight: &'a InFlight, - setup_py: SetupPyStrategy, build_isolation: BuildIsolation<'a>, link_mode: install_wheel_rs::linker::LinkMode, build_options: &'a BuildOptions, @@ -68,7 +66,6 @@ impl<'a> BuildDispatch<'a> { git: &'a GitResolver, in_flight: &'a InFlight, index_strategy: IndexStrategy, - setup_py: SetupPyStrategy, config_settings: &'a ConfigSettings, build_isolation: BuildIsolation<'a>, link_mode: install_wheel_rs::linker::LinkMode, @@ -88,7 +85,6 @@ impl<'a> BuildDispatch<'a> { git, in_flight, index_strategy, - setup_py, config_settings, build_isolation, link_mode, @@ -326,7 +322,6 @@ impl<'a> BuildContext for BuildDispatch<'a> { self, self.source_build_context.clone(), version_id.to_string(), - self.setup_py, self.config_settings.clone(), self.build_isolation, build_kind, diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index d2b7219f2f10..d45ec7714dbe 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -944,16 +944,6 @@ pub struct PipOptions { "# )] pub generate_hashes: Option, - /// Use legacy `setuptools` behavior when building source distributions without a - /// `pyproject.toml`. - #[option( - default = "false", - value_type = "bool", - example = r#" - legacy-setup-py = true - "# - )] - pub legacy_setup_py: Option, /// Settings to pass to the [PEP 517](https://peps.python.org/pep-0517/) build backend, /// specified as `KEY=VALUE` pairs. #[option( diff --git a/crates/uv/src/commands/pip/compile.rs b/crates/uv/src/commands/pip/compile.rs index bb8d3aba6cb8..6dd99f7d4945 100644 --- a/crates/uv/src/commands/pip/compile.rs +++ b/crates/uv/src/commands/pip/compile.rs @@ -16,7 +16,7 @@ use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, IndexStrategy, NoBinary, - NoBuild, Reinstall, SetupPyStrategy, SourceStrategy, Upgrade, + NoBuild, Reinstall, SourceStrategy, Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::BuildDispatch; @@ -73,7 +73,6 @@ pub(crate) async fn pip_compile( index_locations: IndexLocations, index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - setup_py: SetupPyStrategy, config_settings: ConfigSettings, connectivity: Connectivity, no_build_isolation: bool, @@ -322,7 +321,6 @@ pub(crate) async fn pip_compile( &git, &in_flight, index_strategy, - setup_py, &config_settings, build_isolation, link_mode, diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index e24e3fe647f9..cb245ca6de7e 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -14,7 +14,7 @@ use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, HashCheckingMode, - IndexStrategy, Reinstall, SetupPyStrategy, SourceStrategy, Upgrade, + IndexStrategy, Reinstall, SourceStrategy, Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::BuildDispatch; @@ -57,7 +57,6 @@ pub(crate) async fn pip_install( link_mode: LinkMode, compile: bool, hash_checking: Option, - setup_py: SetupPyStrategy, connectivity: Connectivity, config_settings: &ConfigSettings, no_build_isolation: bool, @@ -312,7 +311,6 @@ pub(crate) async fn pip_install( &state.git, &state.in_flight, index_strategy, - setup_py, config_settings, build_isolation, link_mode, diff --git a/crates/uv/src/commands/pip/sync.rs b/crates/uv/src/commands/pip/sync.rs index 1de8ef6597f0..85f5021876ae 100644 --- a/crates/uv/src/commands/pip/sync.rs +++ b/crates/uv/src/commands/pip/sync.rs @@ -13,7 +13,7 @@ use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, HashCheckingMode, - IndexStrategy, Reinstall, SetupPyStrategy, SourceStrategy, Upgrade, + IndexStrategy, Reinstall, SourceStrategy, Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::BuildDispatch; @@ -48,7 +48,6 @@ pub(crate) async fn pip_sync( index_locations: IndexLocations, index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - setup_py: SetupPyStrategy, allow_empty_requirements: bool, connectivity: Connectivity, config_settings: &ConfigSettings, @@ -258,7 +257,6 @@ pub(crate) async fn pip_sync( &state.git, &state.in_flight, index_strategy, - setup_py, config_settings, build_isolation, link_mode, diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index c47d2edc71f1..c2dc96340a57 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -11,7 +11,7 @@ use tracing::debug; use uv_auth::{store_credentials_from_url, Credentials}; use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{Concurrency, ExtrasSpecification, SetupPyStrategy, SourceStrategy}; +use uv_configuration::{Concurrency, ExtrasSpecification, SourceStrategy}; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; use uv_fs::{Simplified, CWD}; @@ -234,7 +234,6 @@ pub(crate) async fn add( let python_version = None; let python_platform = None; let hasher = HashStrategy::default(); - let setup_py = SetupPyStrategy::default(); let build_isolation = BuildIsolation::default(); // Determine the environment for the resolution. @@ -279,7 +278,6 @@ pub(crate) async fn add( &state.git, &state.in_flight, settings.index_strategy, - setup_py, &settings.config_setting, build_isolation, settings.link_mode, diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 5c61fa044b4e..c0bb9445f980 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -14,7 +14,7 @@ use pypi_types::Requirement; use uv_auth::store_credentials_from_url; use uv_cache::Cache; use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{Concurrency, ExtrasSpecification, Reinstall, SetupPyStrategy, Upgrade}; +use uv_configuration::{Concurrency, ExtrasSpecification, Reinstall, Upgrade}; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; use uv_fs::CWD; @@ -347,7 +347,6 @@ async fn do_lock( // optional on the downstream APIs. let build_constraints = []; let extras = ExtrasSpecification::default(); - let setup_py = SetupPyStrategy::default(); // Resolve the flat indexes from `--find-links`. let flat_index = { @@ -368,7 +367,6 @@ async fn do_lock( &state.git, &state.in_flight, index_strategy, - setup_py, config_setting, build_isolation, link_mode, diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 10e7e70cb8bf..69e7bb3aea21 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -11,7 +11,7 @@ use pypi_types::Requirement; use uv_auth::store_credentials_from_url; use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{Concurrency, ExtrasSpecification, Reinstall, SetupPyStrategy, Upgrade}; +use uv_configuration::{Concurrency, ExtrasSpecification, Reinstall, Upgrade}; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; use uv_fs::Simplified; @@ -445,7 +445,6 @@ pub(crate) async fn resolve_names( // TODO(charlie): These are all default values. We should consider whether we want to make them // optional on the downstream APIs. let hasher = HashStrategy::default(); - let setup_py = SetupPyStrategy::default(); let flat_index = FlatIndex::default(); let build_constraints = []; @@ -461,7 +460,6 @@ pub(crate) async fn resolve_names( &state.git, &state.in_flight, *index_strategy, - setup_py, config_setting, build_isolation, *link_mode, @@ -570,7 +568,6 @@ pub(crate) async fn resolve_environment<'a>( let extras = ExtrasSpecification::default(); let hasher = HashStrategy::default(); let preferences = Vec::default(); - let setup_py = SetupPyStrategy::default(); let build_constraints = []; // When resolving from an interpreter, we assume an empty environment, so reinstalls and @@ -597,7 +594,6 @@ pub(crate) async fn resolve_environment<'a>( &state.git, &state.in_flight, index_strategy, - setup_py, config_setting, build_isolation, link_mode, @@ -699,7 +695,6 @@ pub(crate) async fn sync_environment( let build_constraints = []; let dry_run = false; let hasher = HashStrategy::default(); - let setup_py = SetupPyStrategy::default(); // Resolve the flat indexes from `--find-links`. let flat_index = { @@ -720,7 +715,6 @@ pub(crate) async fn sync_environment( &state.git, &state.in_flight, index_strategy, - setup_py, config_setting, build_isolation, link_mode, @@ -893,7 +887,6 @@ pub(crate) async fn update_environment( let extras = ExtrasSpecification::default(); let hasher = HashStrategy::default(); let preferences = Vec::default(); - let setup_py = SetupPyStrategy::default(); // Resolve the flat indexes from `--find-links`. let flat_index = { @@ -914,7 +907,6 @@ pub(crate) async fn update_environment( &state.git, &state.in_flight, *index_strategy, - setup_py, config_setting, build_isolation, *link_mode, diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index fdca62a144b5..8b11c20ec50c 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -3,7 +3,7 @@ use anyhow::{Context, Result}; use uv_auth::store_credentials_from_url; use uv_cache::Cache; use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{Concurrency, ExtrasSpecification, HashCheckingMode, SetupPyStrategy}; +use uv_configuration::{Concurrency, ExtrasSpecification, HashCheckingMode}; use uv_dispatch::BuildDispatch; use uv_fs::CWD; use uv_installer::SitePackages; @@ -200,7 +200,6 @@ pub(super) async fn do_sync( // optional on the downstream APIs. let build_constraints = []; let dry_run = false; - let setup_py = SetupPyStrategy::default(); // Extract the hashes from the lockfile. let hasher = HashStrategy::from_resolution(&resolution, HashCheckingMode::Verify)?; @@ -224,7 +223,6 @@ pub(super) async fn do_sync( &state.git, &state.in_flight, index_strategy, - setup_py, config_setting, build_isolation, link_mode, diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index 7c9a821af5cf..78de5e0a5910 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -17,7 +17,7 @@ use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, IndexStrategy, KeyringProviderType, NoBinary, - NoBuild, SetupPyStrategy, SourceStrategy, + NoBuild, SourceStrategy, }; use uv_dispatch::BuildDispatch; use uv_fs::{Simplified, CWD}; @@ -274,7 +274,6 @@ async fn venv_impl( // For seed packages, assume a bunch of default settings are sufficient. let build_constraints = []; let config_settings = ConfigSettings::default(); - let setup_py = SetupPyStrategy::default(); let sources = SourceStrategy::Disabled; // Do not allow builds @@ -292,7 +291,6 @@ async fn venv_impl( &state.git, &state.in_flight, index_strategy, - setup_py, &config_settings, BuildIsolation::Isolated, link_mode, diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index bcea1ec94fe0..28cd7be037c4 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -306,7 +306,6 @@ async fn run(cli: Cli) -> Result { args.settings.index_locations, args.settings.index_strategy, args.settings.keyring_provider, - args.settings.setup_py, args.settings.config_setting, globals.connectivity, args.settings.no_build_isolation, @@ -373,7 +372,6 @@ async fn run(cli: Cli) -> Result { args.settings.index_locations, args.settings.index_strategy, args.settings.keyring_provider, - args.settings.setup_py, args.settings.allow_empty_requirements, globals.connectivity, &args.settings.config_setting, @@ -461,7 +459,6 @@ async fn run(cli: Cli) -> Result { args.settings.link_mode, args.settings.compile_bytecode, args.settings.hash_checking, - args.settings.setup_py, globals.connectivity, &args.settings.config_setting, args.settings.no_build_isolation, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 24ca92d7adb4..5e052c37e5bf 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -23,8 +23,8 @@ use uv_cli::{ use uv_client::Connectivity; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, HashCheckingMode, - IndexStrategy, KeyringProviderType, NoBinary, NoBuild, PreviewMode, Reinstall, SetupPyStrategy, - SourceStrategy, TargetTriple, Upgrade, + IndexStrategy, KeyringProviderType, NoBinary, NoBuild, PreviewMode, Reinstall, SourceStrategy, + TargetTriple, Upgrade, }; use uv_normalize::PackageName; use uv_python::{Prefix, PythonDownloads, PythonPreference, PythonVersion, Target}; @@ -937,8 +937,6 @@ impl PipCompileSettings { no_system, generate_hashes, no_generate_hashes, - legacy_setup_py, - no_legacy_setup_py, no_build, build, no_binary, @@ -1023,7 +1021,6 @@ impl PipCompileSettings { no_header: flag(no_header, header), custom_compile_command, generate_hashes: flag(generate_hashes, no_generate_hashes), - legacy_setup_py: flag(legacy_setup_py, no_legacy_setup_py), python_version, python_platform, universal: flag(universal, no_universal), @@ -1076,8 +1073,6 @@ impl PipSyncSettings { prefix, allow_empty_requirements, no_allow_empty_requirements, - legacy_setup_py, - no_legacy_setup_py, no_build, build, no_binary, @@ -1118,7 +1113,6 @@ impl PipSyncSettings { allow_empty_requirements, no_allow_empty_requirements, ), - legacy_setup_py: flag(legacy_setup_py, no_legacy_setup_py), python_version, python_platform, strict: flag(strict, no_strict), @@ -1175,8 +1169,6 @@ impl PipInstallSettings { no_break_system_packages, target, prefix, - legacy_setup_py, - no_legacy_setup_py, no_build, build, no_binary, @@ -1251,7 +1243,6 @@ impl PipInstallSettings { extra, all_extras: flag(all_extras, no_all_extras), no_deps: flag(no_deps, deps), - legacy_setup_py: flag(legacy_setup_py, no_legacy_setup_py), python_version, python_platform, require_hashes: flag(require_hashes, no_require_hashes), @@ -1839,7 +1830,6 @@ pub(crate) struct PipSettings { pub(crate) no_header: bool, pub(crate) custom_compile_command: Option, pub(crate) generate_hashes: bool, - pub(crate) setup_py: SetupPyStrategy, pub(crate) config_setting: ConfigSettings, pub(crate) python_version: Option, pub(crate) python_platform: Option, @@ -1898,7 +1888,6 @@ impl PipSettings { no_header, custom_compile_command, generate_hashes, - legacy_setup_py, config_settings, python_version, python_platform, @@ -2025,15 +2014,6 @@ impl PipSettings { .allow_empty_requirements .combine(allow_empty_requirements) .unwrap_or_default(), - setup_py: if args - .legacy_setup_py - .combine(legacy_setup_py) - .unwrap_or_default() - { - SetupPyStrategy::Setuptools - } else { - SetupPyStrategy::Pep517 - }, no_build_isolation: args .no_build_isolation .combine(no_build_isolation) diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 25133a914490..a67249c17ffe 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -4119,7 +4119,7 @@ fn trailing_slash() -> Result<()> { Ok(()) } -/// Resolve a project without a `pyproject.toml`, using the PEP 517 build backend (default). +/// Resolve a project without a `pyproject.toml`, using the PEP 517 build backend. #[test] fn compile_legacy_sdist_pep_517() -> Result<()> { let context = TestContext::new("3.12"); @@ -4150,38 +4150,6 @@ fn compile_legacy_sdist_pep_517() -> Result<()> { Ok(()) } -/// Resolve a project without a `pyproject.toml`, using `setuptools` directly. -#[test] -fn compile_legacy_sdist_setuptools() -> Result<()> { - let context = TestContext::new("3.12"); - let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str("flake8 @ https://files.pythonhosted.org/packages/66/53/3ad4a3b74d609b3b9008a10075c40e7c8909eae60af53623c3888f7a529a/flake8-6.0.0.tar.gz")?; - - uv_snapshot!(context.filters(), context.pip_compile() - .arg("requirements.in") - .arg("--legacy-setup-py"), @r###" - success: true - exit_code: 0 - ----- stdout ----- - # This file was autogenerated by uv via the following command: - # uv pip compile --cache-dir [CACHE_DIR] requirements.in --legacy-setup-py - flake8 @ https://files.pythonhosted.org/packages/66/53/3ad4a3b74d609b3b9008a10075c40e7c8909eae60af53623c3888f7a529a/flake8-6.0.0.tar.gz - # via -r requirements.in - mccabe==0.7.0 - # via flake8 - pycodestyle==2.10.0 - # via flake8 - pyflakes==3.0.1 - # via flake8 - - ----- stderr ----- - Resolved 4 packages in [TIME] - "### - ); - - Ok(()) -} - /// Include hashes from the registry in the generated output. #[test] fn generate_hashes_registry() -> Result<()> { diff --git a/crates/uv/tests/pip_sync.rs b/crates/uv/tests/pip_sync.rs index 605500ab2866..fea66d8561ec 100644 --- a/crates/uv/tests/pip_sync.rs +++ b/crates/uv/tests/pip_sync.rs @@ -2619,7 +2619,7 @@ fn incompatible_wheel() -> Result<()> { Ok(()) } -/// Install a project without a `pyproject.toml`, using the PEP 517 build backend (default). +/// Install a project without a `pyproject.toml`, using the PEP 517 build backend. #[test] fn sync_legacy_sdist_pep_517() -> Result<()> { let context = TestContext::new("3.12"); @@ -2644,32 +2644,6 @@ fn sync_legacy_sdist_pep_517() -> Result<()> { Ok(()) } -/// Install a project without a `pyproject.toml`, using `setuptools` directly. -#[test] -fn sync_legacy_sdist_setuptools() -> Result<()> { - let context = TestContext::new("3.12"); - - let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str("flake8 @ https://files.pythonhosted.org/packages/66/53/3ad4a3b74d609b3b9008a10075c40e7c8909eae60af53623c3888f7a529a/flake8-6.0.0.tar.gz")?; - - uv_snapshot!(context.pip_sync() - .arg("requirements.in") - .arg("--legacy-setup-py"), @r###" - success: true - exit_code: 0 - ----- stdout ----- - - ----- stderr ----- - Resolved 1 package in [TIME] - Prepared 1 package in [TIME] - Installed 1 package in [TIME] - + flake8==6.0.0 (from https://files.pythonhosted.org/packages/66/53/3ad4a3b74d609b3b9008a10075c40e7c8909eae60af53623c3888f7a529a/flake8-6.0.0.tar.gz) - "### - ); - - Ok(()) -} - /// Sync using `--find-links` with a local directory. #[test] fn find_links() -> Result<()> { diff --git a/crates/uv/tests/show_settings.rs b/crates/uv/tests/show_settings.rs index ee9b5aa1a734..5862c7046b6e 100644 --- a/crates/uv/tests/show_settings.rs +++ b/crates/uv/tests/show_settings.rs @@ -143,7 +143,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -279,7 +278,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -416,7 +414,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -585,7 +582,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -700,7 +696,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -847,7 +842,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1031,7 +1025,6 @@ fn resolve_index_url() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1214,7 +1207,6 @@ fn resolve_index_url() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1375,7 +1367,6 @@ fn resolve_find_links() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1512,7 +1503,6 @@ fn resolve_top_level() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1687,7 +1677,6 @@ fn resolve_top_level() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1845,7 +1834,6 @@ fn resolve_top_level() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -1982,7 +1970,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2102,7 +2089,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2222,7 +2208,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2344,7 +2329,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2636,7 +2620,6 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2807,7 +2790,6 @@ fn resolve_both() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -2970,7 +2952,6 @@ fn resolve_config_file() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: true, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -3185,7 +3166,6 @@ fn resolve_skip_empty() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), @@ -3308,7 +3288,6 @@ fn resolve_skip_empty() -> anyhow::Result<()> { no_header: false, custom_compile_command: None, generate_hashes: false, - setup_py: Pep517, config_setting: ConfigSettings( {}, ), diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 17db09420a4a..ef9fdb99c34c 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -3676,8 +3676,6 @@ uv pip compile [OPTIONS] ...
  • subprocess: Use the keyring command for credential lookup
  • -
    --legacy-setup-py

    Use legacy setuptools behavior when building source distributions without a pyproject.toml

    -
    --link-mode link-mode

    The method to use when installing packages from the global cache.

    This option is only used when building source distributions.

    @@ -4017,8 +4015,6 @@ uv pip sync [OPTIONS] ...
  • subprocess: Use the keyring command for credential lookup
  • -
    --legacy-setup-py

    Use legacy setuptools behavior when building source distributions without a pyproject.toml

    -
    --link-mode link-mode

    The method to use when installing packages from the global cache.

    Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

    @@ -4314,8 +4310,6 @@ uv pip install [OPTIONS] |--editable subprocess: Use the keyring command for credential lookup -
    --legacy-setup-py

    Use legacy setuptools behavior when building source distributions without a pyproject.toml

    -
    --link-mode link-mode

    The method to use when installing packages from the global cache.

    Defaults to clone (also known as Copy-on-Write) on macOS, and hardlink on Linux and Windows.

    diff --git a/docs/reference/settings.md b/docs/reference/settings.md index 30a7b411fd95..196fe3b40781 100644 --- a/docs/reference/settings.md +++ b/docs/reference/settings.md @@ -1568,33 +1568,6 @@ use the `keyring` CLI to handle authentication. --- -#### [`legacy-setup-py`](#pip_legacy-setup-py) {: #pip_legacy-setup-py } - - -Use legacy `setuptools` behavior when building source distributions without a -`pyproject.toml`. - -**Default value**: `false` - -**Type**: `bool` - -**Example usage**: - -=== "pyproject.toml" - - ```toml - [tool.uv.pip] - legacy-setup-py = true - ``` -=== "uv.toml" - - ```toml - [pip] - legacy-setup-py = true - ``` - ---- - #### [`link-mode`](#pip_link-mode) {: #pip_link-mode } diff --git a/uv.schema.json b/uv.schema.json index 94bf6bc31952..fbeb7de83ab0 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -711,13 +711,6 @@ } ] }, - "legacy-setup-py": { - "description": "Use legacy `setuptools` behavior when building source distributions without a `pyproject.toml`.", - "type": [ - "boolean", - "null" - ] - }, "link-mode": { "description": "The method to use when installing packages from the global cache.\n\nDefaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and Windows.", "anyOf": [