Skip to content

Commit

Permalink
Add PEP 517 config_settings support
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 c840a76 commit 7d0b815
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 26 deletions.
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 7d0b815

Please sign in to comment.