Skip to content

Commit

Permalink
Add PEP 517 config_settings support (#1619)
Browse files Browse the repository at this point in the history
Replaces `MATURIN_PEP517_ARGS` environment variable with
`--config-settings build-args=<cargo build args>`.
  • Loading branch information
messense committed May 20, 2023
1 parent 37f0db4 commit f66a0c8
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 28 deletions.
6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.15.2] - 2023-05-16

* When determining the python module name, use pyproject.toml `project.name` over Cargo.toml `package.name` in [#1608](https://github.com/PyO3/maturin/pull/1608)
* Fix rewriting `dev-dependencies` in sdist in [#1610](https://github.com/PyO3/maturin/pull/1610)
* When determining the python module name, use pyproject.toml `project.name` over Cargo.toml `package.name` in [#1608](https://github.com/PyO3/maturin/pull/1608)
* Fix rewriting `dev-dependencies` in sdist in [#1610](https://github.com/PyO3/maturin/pull/1610)
* Add PEP 517 `config_settings` support in [#1619](https://github.com/PyO3/maturin/pull/1619),
deprecate `MATURIN_PEP517_ARGS` in favor of the new `build-args` config setting.

## [0.15.1] - 2023-05-07

Expand Down
20 changes: 15 additions & 5 deletions maturin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,19 @@ def get_config() -> Dict[str, str]:
return pyproject_toml.get("tool", {}).get("maturin", {})


def get_maturin_pep517_args() -> list[str]:
args = shlex.split(os.getenv("MATURIN_PEP517_ARGS", ""))
return args
def get_maturin_pep517_args(
config_settings: Mapping[str, Any] | None = None
) -> list[str]:
build_args = config_settings.get("build-args") if config_settings else None
if build_args is None:
args = os.getenv("MATURIN_PEP517_ARGS", "")
if args:
print(
f"'MATURIN_PEP517_ARGS' is deprecated, use `--config-settings build-args='{args}'` instead."
)
else:
args = build_args
return shlex.split(args)


def _additional_pep517_args() -> list[str]:
Expand Down Expand Up @@ -68,7 +78,7 @@ def _build_wheel(
if editable:
command.append("--editable")

pep517_args = get_maturin_pep517_args()
pep517_args = get_maturin_pep517_args(config_settings)
if pep517_args:
command.extend(pep517_args)

Expand Down Expand Up @@ -185,7 +195,7 @@ def prepare_metadata_for_build_wheel(
sys.executable,
]
command.extend(_additional_pep517_args())
pep517_args = get_maturin_pep517_args()
pep517_args = get_maturin_pep517_args(config_settings)
if pep517_args:
command.extend(pep517_args)

Expand Down
2 changes: 1 addition & 1 deletion test-crates/cffi-mixed/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/cffi-pure/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/hello-world/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[tool.maturin]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/lib_with_disallowed_lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/lib_with_path_dep/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/license-test/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-ffi-pure/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-include-exclude/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-py-subdir/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-submodule/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-pure/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[tool.maturin]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/sdist_with_path_dep/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/sdist_with_target_path_dep/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/uniffi-mixed/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/uniffi-pure/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/with-data/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[project]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/workspace-inheritance/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/workspace/py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"
2 changes: 1 addition & 1 deletion test-crates/workspace_with_path_dep/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=0.15,<0.16"]
build-backend = "maturin"

[tool.maturin]
Expand Down

0 comments on commit f66a0c8

Please sign in to comment.