Default to PEP 517-based builds (#843)
## Summary Our current setup uses the legacy `setup.py`-based builds if a `pyproject.toml` file isn't present. This matches pip's behavior. However, `pypa/build` uses PEP 517-based builds in such cases, and it looks like pip plans to make that the default (https://github.com/pypa/pip/issues/9175), with the limiting factor being performance issues related to isolated builds. This is now the default behavior, but the `--legacy-setup-py` flag allows users to opt-in to using `setup.py` directly for distributions that lack a `pyproject.toml`.
This commit is contained in:
@@ -23,6 +23,7 @@ use puffin_installer::Downloader;
|
||||
use puffin_interpreter::{Interpreter, PythonVersion};
|
||||
use puffin_normalize::ExtraName;
|
||||
use puffin_resolver::{Manifest, PreReleaseMode, ResolutionMode, ResolutionOptions, Resolver};
|
||||
use puffin_traits::SetupPyStrategy;
|
||||
use requirements_txt::EditableRequirement;
|
||||
|
||||
use crate::commands::reporters::{DownloadReporter, ResolverReporter};
|
||||
@@ -44,6 +45,7 @@ pub(crate) async fn pip_compile(
|
||||
prerelease_mode: PreReleaseMode,
|
||||
upgrade_mode: UpgradeMode,
|
||||
index_urls: IndexUrls,
|
||||
setup_py: SetupPyStrategy,
|
||||
no_build: bool,
|
||||
python_version: Option<PythonVersion>,
|
||||
exclude_newer: Option<DateTime<Utc>>,
|
||||
@@ -141,6 +143,7 @@ pub(crate) async fn pip_compile(
|
||||
&interpreter,
|
||||
&index_urls,
|
||||
interpreter.sys_executable().to_path_buf(),
|
||||
setup_py,
|
||||
no_build,
|
||||
)
|
||||
.with_options(options);
|
||||
|
||||
@@ -28,7 +28,7 @@ use puffin_normalize::PackageName;
|
||||
use puffin_resolver::{
|
||||
Manifest, PreReleaseMode, ResolutionGraph, ResolutionMode, ResolutionOptions, Resolver,
|
||||
};
|
||||
use puffin_traits::OnceMap;
|
||||
use puffin_traits::{OnceMap, SetupPyStrategy};
|
||||
use requirements_txt::EditableRequirement;
|
||||
|
||||
use crate::commands::reporters::{DownloadReporter, InstallReporter, ResolverReporter};
|
||||
@@ -48,6 +48,7 @@ pub(crate) async fn pip_install(
|
||||
index_urls: IndexUrls,
|
||||
reinstall: &Reinstall,
|
||||
link_mode: LinkMode,
|
||||
setup_py: SetupPyStrategy,
|
||||
no_build: bool,
|
||||
strict: bool,
|
||||
exclude_newer: Option<DateTime<Utc>>,
|
||||
@@ -144,6 +145,7 @@ pub(crate) async fn pip_install(
|
||||
&interpreter,
|
||||
&index_urls,
|
||||
venv.python_executable(),
|
||||
setup_py,
|
||||
no_build,
|
||||
)
|
||||
.with_options(options);
|
||||
|
||||
@@ -14,7 +14,7 @@ use puffin_client::{RegistryClient, RegistryClientBuilder};
|
||||
use puffin_dispatch::BuildDispatch;
|
||||
use puffin_installer::{Downloader, InstallPlan, Reinstall, ResolvedEditable, SitePackages};
|
||||
use puffin_interpreter::Virtualenv;
|
||||
use puffin_traits::OnceMap;
|
||||
use puffin_traits::{OnceMap, SetupPyStrategy};
|
||||
use pypi_types::Yanked;
|
||||
use requirements_txt::EditableRequirement;
|
||||
|
||||
@@ -30,6 +30,7 @@ pub(crate) async fn pip_sync(
|
||||
reinstall: &Reinstall,
|
||||
link_mode: LinkMode,
|
||||
index_urls: IndexUrls,
|
||||
setup_py: SetupPyStrategy,
|
||||
no_build: bool,
|
||||
strict: bool,
|
||||
cache: Cache,
|
||||
@@ -69,6 +70,7 @@ pub(crate) async fn pip_sync(
|
||||
venv.interpreter(),
|
||||
&index_urls,
|
||||
venv.python_executable(),
|
||||
setup_py,
|
||||
no_build,
|
||||
);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ use puffin_installer::Reinstall;
|
||||
use puffin_interpreter::PythonVersion;
|
||||
use puffin_normalize::{ExtraName, PackageName};
|
||||
use puffin_resolver::{PreReleaseMode, ResolutionMode};
|
||||
use puffin_traits::SetupPyStrategy;
|
||||
use requirements::ExtrasSpecification;
|
||||
|
||||
use crate::commands::{extra_name_with_clap_error, ExitStatus};
|
||||
@@ -166,6 +167,11 @@ struct PipCompileArgs {
|
||||
#[clap(long)]
|
||||
upgrade: bool,
|
||||
|
||||
/// Use legacy `setuptools` behavior when building source distributions without a
|
||||
/// `pyproject.toml`.
|
||||
#[clap(long)]
|
||||
legacy_setup_py: bool,
|
||||
|
||||
/// Don't build source distributions.
|
||||
///
|
||||
/// When enabled, resolving will not run arbitrary code. The cached wheels of already-built
|
||||
@@ -228,6 +234,11 @@ struct PipSyncArgs {
|
||||
#[clap(long, conflicts_with = "index_url", conflicts_with = "extra_index_url")]
|
||||
no_index: bool,
|
||||
|
||||
/// Use legacy `setuptools` behavior when building source distributions without a
|
||||
/// `pyproject.toml`.
|
||||
#[clap(long)]
|
||||
legacy_setup_py: bool,
|
||||
|
||||
/// Don't build source distributions.
|
||||
///
|
||||
/// When enabled, resolving will not run arbitrary code. The cached wheels of already-built
|
||||
@@ -324,6 +335,11 @@ struct PipInstallArgs {
|
||||
#[clap(long, conflicts_with = "index_url", conflicts_with = "extra_index_url")]
|
||||
no_index: bool,
|
||||
|
||||
/// Use legacy `setuptools` behavior when building source distributions without a
|
||||
/// `pyproject.toml`.
|
||||
#[clap(long)]
|
||||
legacy_setup_py: bool,
|
||||
|
||||
/// Don't build source distributions.
|
||||
///
|
||||
/// When enabled, resolving will not run arbitrary code. The cached wheels of already-built
|
||||
@@ -480,6 +496,11 @@ async fn inner() -> Result<ExitStatus> {
|
||||
args.prerelease,
|
||||
args.upgrade.into(),
|
||||
index_urls,
|
||||
if args.legacy_setup_py {
|
||||
SetupPyStrategy::Setuptools
|
||||
} else {
|
||||
SetupPyStrategy::Pep517
|
||||
},
|
||||
args.no_build,
|
||||
args.python_version,
|
||||
args.exclude_newer,
|
||||
@@ -502,6 +523,11 @@ async fn inner() -> Result<ExitStatus> {
|
||||
&reinstall,
|
||||
args.link_mode,
|
||||
index_urls,
|
||||
if args.legacy_setup_py {
|
||||
SetupPyStrategy::Setuptools
|
||||
} else {
|
||||
SetupPyStrategy::Pep517
|
||||
},
|
||||
args.no_build,
|
||||
args.strict,
|
||||
cache,
|
||||
@@ -547,6 +573,11 @@ async fn inner() -> Result<ExitStatus> {
|
||||
index_urls,
|
||||
&reinstall,
|
||||
args.link_mode,
|
||||
if args.legacy_setup_py {
|
||||
SetupPyStrategy::Setuptools
|
||||
} else {
|
||||
SetupPyStrategy::Pep517
|
||||
},
|
||||
args.no_build,
|
||||
args.strict,
|
||||
args.exclude_newer,
|
||||
|
||||
Reference in New Issue
Block a user