forked from openwrt/packages
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python-setuptools-rust: Set cargo profile from environment variable
This adds a patch (submitted upstream in PyO3/setuptools-rust#364), to read the profile to pass to cargo from an environment variable. This also updates the Python include files to set the environment variable based on values from rust-values.mk. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../patches/0001-Allow-profile-to-be-set-by-SETUPTOOLS_RUST_CARGO_PROFILE-env-variable.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From b10cab4efeb80abb5a236d651c9ff9355e470527 Mon Sep 17 00:00:00 2001 | ||
From: Jeffery To <jeffery.to@gmail.com> | ||
Date: Mon, 2 Oct 2023 16:13:51 +0800 | ||
Subject: [PATCH] Allow profile to be set by SETUPTOOLS_RUST_CARGO_PROFILE env | ||
variable | ||
|
||
This allows the profile to be set dynamically, without having to edit | ||
pyproject.toml/setup.py. | ||
--- | ||
setuptools_rust/build.py | 20 ++++++++++++++++---- | ||
1 file changed, 16 insertions(+), 4 deletions(-) | ||
|
||
--- a/setuptools_rust/build.py | ||
+++ b/setuptools_rust/build.py | ||
@@ -528,10 +528,10 @@ class build_rust(RustCommand): | ||
if target_triple is not None: | ||
args.extend(["--target", target_triple]) | ||
|
||
- if release: | ||
- profile = ext.get_cargo_profile() | ||
- if not profile: | ||
- args.append("--release") | ||
+ ext_profile = ext.get_cargo_profile() | ||
+ env_profile = os.getenv("SETUPTOOLS_RUST_CARGO_PROFILE") | ||
+ if release and not ext_profile and not env_profile: | ||
+ args.append("--release") | ||
|
||
if quiet: | ||
args.append("-q") | ||
@@ -552,6 +552,18 @@ class build_rust(RustCommand): | ||
if ext.args is not None: | ||
args.extend(ext.args) | ||
|
||
+ if env_profile: | ||
+ if ext_profile: | ||
+ args = [p for p in args if not p.startswith("--profile=")] | ||
+ while True: | ||
+ try: | ||
+ index = args.index("--profile") | ||
+ del args[index:index + 2] | ||
+ except ValueError: | ||
+ break | ||
+ | ||
+ args.extend(["--profile", env_profile]) | ||
+ | ||
if ext.cargo_manifest_args is not None: | ||
args.extend(ext.cargo_manifest_args) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters