python: Add environment variables to build Rust extensions
authorJeffery To <jeffery.to@gmail.com>
Wed, 13 Sep 2023 04:15:18 +0000 (12:15 +0800)
committerRosen Penev <rosenp@gmail.com>
Wed, 27 Sep 2023 23:40:55 +0000 (16:40 -0700)
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python3-host.mk
lang/python/python3-package.mk

index b272c28ca1ab23d928c42480260c1a58b9a376bc..ca5cb64baacc31e607eca4fe56ca4047a0866924 100644 (file)
@@ -11,6 +11,7 @@
 # For PYTHON3_VERSION
 python3_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
 include $(python3_mk_path)python3-version.mk
+include $(python3_mk_path)../rust/rust-values.mk
 
 # Unset environment variables
 
@@ -76,7 +77,9 @@ HOST_PYTHON3_VARS = \
        LDSHARED="$(HOSTCC) -shared" \
        CFLAGS="$(HOST_CFLAGS)" \
        CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
-       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib"
+       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib" \
+       CARGO_HOME="$(CARGO_HOME)" \
+       PATH="$(CARGO_HOME)/bin:$(PATH)"
 
 # $(1) => directory of python script
 # $(2) => python script and its arguments
index 268bca07f98dbf27ebf6868312ae274bcf6d21ff..0693d21ee0694f3361e0111cdf2e9db0e62547d1 100644 (file)
@@ -44,7 +44,12 @@ PYTHON3_VARS = \
        PYTHONDONTWRITEBYTECODE=1 \
        _python_sysroot="$(STAGING_DIR)" \
        _python_prefix="/usr" \
-       _python_exec_prefix="/usr"
+       _python_exec_prefix="/usr" \
+       CARGO_BUILD_TARGET="$(RUSTC_TARGET_ARCH)" \
+       CARGO_HOME="$(CARGO_HOME)" \
+       PATH="$(CARGO_HOME)/bin:$(PATH)" \
+       PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)" \
+       RUSTFLAGS="$(CARGO_RUSTFLAGS)"
 
 # $(1) => directory of python script
 # $(2) => python script and its arguments