Skip to content

Commit

Permalink
Build with --no-default-features by default when bootstrapping from…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
messense committed Dec 5, 2022
1 parent 8da105a commit 79aaf9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 10 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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 <source dir>` are supported. For creating a source distribution
# `pip install <source dir>`) are supported. For creating a source distribution
# for maturin itself use `maturin sdist`.

import platform
import sys
import os

try:
import tomllib
Expand All @@ -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
Expand All @@ -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",
Expand Down

0 comments on commit 79aaf9e

Please sign in to comment.