From 79aaf9e6a58f22cafdd2205c1672d370f8273876 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 5 Dec 2022 22:40:20 +0800 Subject: [PATCH] Build with `--no-default-features` by default when bootstrapping from sdist Cargo features can be customized with the `MATURIN_SETUP_ARGS` env var, for example: ``` export MATURIN_SETUP_ARGS="--features upload" python setup.py bdist_wheel ``` The above command will override `--no-default-features` and pass `--features upload` instead. --- Changelog.md | 2 ++ setup.py | 31 ++++++++++--------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Changelog.md b/Changelog.md index 709f03d7d..e39a39789 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* **Breaking Change**: Build with `--no-default-features` by default when bootstrapping from sdist in [#1333](https://github.com/PyO3/maturin/pull/1333) + ## [0.14.4] - 2022-12-05 * Expanded architecture support for FreeBSD, NetBSD and OpenBSD in [#1318](https://github.com/PyO3/maturin/pull/1318) diff --git a/setup.py b/setup.py index 7da79c76c..a3cfead26 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,15 @@ -# maturin is self bootstraping, however on platforms like alpine linux that aren't -# manylinux, pip will try installing maturin from the source distribution. +# maturin is self bootstrapping, however on platforms like FreeBSD that aren't +# manylinux/musllinux, pip will try installing maturin from the source distribution. # That source distribution obviously can't depend on maturin, so we're using # the always available setuptools. # # Note that this is really only a workaround for bootstrapping and not suited # for general purpose packaging, i.e. only building a wheel (as in # `python setup.py bdist_wheel`) and installing (as in -# `pip install ` are supported. For creating a source distribution +# `pip install `) are supported. For creating a source distribution # for maturin itself use `maturin sdist`. -import platform -import sys +import os try: import tomllib @@ -24,7 +23,7 @@ # https://stackoverflow.com/a/45150383/3549270 # There's also the much more concise solution in # https://stackoverflow.com/a/53463910/3549270, -# but that would requires python-dev +# but that would require python-dev try: # noinspection PyPackageRequirements,PyUnresolvedReferences from wheel.bdist_wheel import bdist_wheel as _bdist_wheel @@ -44,21 +43,11 @@ def finalize_options(self): with open("Cargo.toml", "rb") as fp: version = tomllib.load(fp)["package"]["version"] -cargo_args = [] -if platform.machine() in ( - "mips", - "mips64", - "ppc", - "ppc64le", - "ppc64", - "powerpc", - "riscv64", - "sparc64", -) or (sys.platform == "win32" and platform.machine() == "ARM64"): - cargo_args.extend(["--no-default-features", "--features=upload,log"]) -elif sys.platform.startswith("haiku"): - # mio and ring doesn't build on haiku - cargo_args.extend(["--no-default-features", "--features=log"]) +# Use `--no-default-features` by default for a minimal build to support PEP 517. +# `MATURIN_SETUP_ARGS` env var can be used to pass customized arguments to cargo. +cargo_args = ["--no-default-features"] +if os.getenv("MATURIN_SETUP_ARGS"): + cargo_args = os.getenv("MATURIN_SETUP_ARGS").split() setup( name="maturin",