Skip to content

Commit

Permalink
python: Add environment variables to build Rust extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffery To <[email protected]>
  • Loading branch information
jefferyto authored and neheb committed Sep 27, 2023
1 parent f467f47 commit 4d43be8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lang/python/python3-host.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lang/python/python3-package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d43be8

Please sign in to comment.