Skip to content

Commit f3f6b21

Browse files
Infer python version from Makefile.envs in PyO3 (#19)
Instead of hardcoding the Python version, use `PYO3_CROSS_PYTHON_VERSION` env variable, which [PyO3 uses to find the correct Python include/lib paths](https://pyo3.rs/main/building-and-distribution#cross-compiling). Also removed pyo3_config.ini file. Otherwise, the config file always take precedence. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent fca5d09 commit f3f6b21

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Changed
11+
12+
- `pyo3_config_file` is no longer available in `pyodide config` command.
13+
Pyodide now sets `PYO3_CROSS_PYTHON_VERSION`, `PYO3_CROSS_LIB_DIR` to specify the cross compilation environment
14+
for PyO3.
15+
[#19](https://github.com/pyodide/pyodide-build/pull/19)
16+
1017
## [0.28.0] - 2024/08/14
1118

1219
- `pyodide xbuildenv` subcommand is now publicly available.

pyodide_build/cli/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"python_version": "PYVERSION",
1212
"rustflags": "RUSTFLAGS",
1313
"cmake_toolchain_file": "CMAKE_TOOLCHAIN_FILE",
14-
"pyo3_config_file": "PYO3_CONFIG_FILE",
1514
"rust_toolchain": "RUST_TOOLCHAIN",
1615
"cflags": "SIDE_MODULE_CFLAGS",
1716
"cxxflags": "SIDE_MODULE_CXXFLAGS",

pyodide_build/config.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def to_env(self) -> dict[str, str]:
143143
"pyminor": "PYMINOR",
144144
"pyo3_cross_include_dir": "PYO3_CROSS_INCLUDE_DIR",
145145
"pyo3_cross_lib_dir": "PYO3_CROSS_LIB_DIR",
146+
"pyo3_cross_python_version": "PYO3_CROSS_PYTHON_VERSION",
146147
"pyodide_emscripten_version": "PYODIDE_EMSCRIPTEN_VERSION",
147148
"pyodide_jobs": "PYODIDE_JOBS",
148149
"pyodide_root": "PYODIDE_ROOT",
@@ -161,7 +162,6 @@ def to_env(self) -> dict[str, str]:
161162
"sysconfig_name": "SYSCONFIG_NAME",
162163
"targetinstalldir": "TARGETINSTALLDIR",
163164
"cmake_toolchain_file": "CMAKE_TOOLCHAIN_FILE",
164-
"pyo3_config_file": "PYO3_CONFIG_FILE",
165165
"meson_cross_file": "MESON_CROSS_FILE",
166166
"cflags_base": "CFLAGS_BASE",
167167
"cxxflags_base": "CXXFLAGS_BASE",
@@ -192,7 +192,6 @@ def to_env(self) -> dict[str, str]:
192192
DEFAULT_CONFIG: dict[str, str] = {
193193
# Paths to toolchain configuration files
194194
"cmake_toolchain_file": str(TOOLS_DIR / "cmake/Modules/Platform/Emscripten.cmake"),
195-
"pyo3_config_file": str(TOOLS_DIR / "pyo3_config.ini"),
196195
"meson_cross_file": str(TOOLS_DIR / "emscripten.meson.cross"),
197196
# Rust-specific configuration
198197
"rustflags": "-C link-arg=-sSIDE_MODULE=2 -C link-arg=-sWASM_BIGINT -Z link-native-libraries=no",
@@ -213,8 +212,9 @@ def to_env(self) -> dict[str, str]:
213212
"cxxflags": "$(CXXFLAGS_BASE)",
214213
"ldflags": "$(LDFLAGS_BASE) -s SIDE_MODULE=1",
215214
# Rust-specific configuration
216-
"pyo3_cross_lib_dir": "$(CPYTHONINSTALL)/lib",
215+
"pyo3_cross_lib_dir": "$(CPYTHONINSTALL)/sysconfigdata", # FIXME: pyodide xbuildenv stores sysconfigdata here
217216
"pyo3_cross_include_dir": "$(PYTHONINCLUDE)",
217+
"pyo3_cross_python_version": "$(PYMAJOR).$(PYMINOR)",
218218
# Misc
219219
"stdlib_module_cflags": "$(CFLAGS_BASE) -I$(PYTHONINCLUDE) -I Include/ -I. -IInclude/internal/", # TODO: remove this
220220
# Paths to build dependencies

pyodide_build/tools/pyo3_config.ini

-7
This file was deleted.

0 commit comments

Comments
 (0)