Skip to content

Commit

Permalink
Infer python version from Makefile.envs in PyO3 (#19)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ryanking13 and pre-commit-ci[bot] authored Aug 24, 2024
1 parent fca5d09 commit f3f6b21
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

- `pyo3_config_file` is no longer available in `pyodide config` command.
Pyodide now sets `PYO3_CROSS_PYTHON_VERSION`, `PYO3_CROSS_LIB_DIR` to specify the cross compilation environment
for PyO3.
[#19](https://github.com/pyodide/pyodide-build/pull/19)

## [0.28.0] - 2024/08/14

- `pyodide xbuildenv` subcommand is now publicly available.
Expand Down
1 change: 0 additions & 1 deletion pyodide_build/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"python_version": "PYVERSION",
"rustflags": "RUSTFLAGS",
"cmake_toolchain_file": "CMAKE_TOOLCHAIN_FILE",
"pyo3_config_file": "PYO3_CONFIG_FILE",
"rust_toolchain": "RUST_TOOLCHAIN",
"cflags": "SIDE_MODULE_CFLAGS",
"cxxflags": "SIDE_MODULE_CXXFLAGS",
Expand Down
6 changes: 3 additions & 3 deletions pyodide_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def to_env(self) -> dict[str, str]:
"pyminor": "PYMINOR",
"pyo3_cross_include_dir": "PYO3_CROSS_INCLUDE_DIR",
"pyo3_cross_lib_dir": "PYO3_CROSS_LIB_DIR",
"pyo3_cross_python_version": "PYO3_CROSS_PYTHON_VERSION",
"pyodide_emscripten_version": "PYODIDE_EMSCRIPTEN_VERSION",
"pyodide_jobs": "PYODIDE_JOBS",
"pyodide_root": "PYODIDE_ROOT",
Expand All @@ -161,7 +162,6 @@ def to_env(self) -> dict[str, str]:
"sysconfig_name": "SYSCONFIG_NAME",
"targetinstalldir": "TARGETINSTALLDIR",
"cmake_toolchain_file": "CMAKE_TOOLCHAIN_FILE",
"pyo3_config_file": "PYO3_CONFIG_FILE",
"meson_cross_file": "MESON_CROSS_FILE",
"cflags_base": "CFLAGS_BASE",
"cxxflags_base": "CXXFLAGS_BASE",
Expand Down Expand Up @@ -192,7 +192,6 @@ def to_env(self) -> dict[str, str]:
DEFAULT_CONFIG: dict[str, str] = {
# Paths to toolchain configuration files
"cmake_toolchain_file": str(TOOLS_DIR / "cmake/Modules/Platform/Emscripten.cmake"),
"pyo3_config_file": str(TOOLS_DIR / "pyo3_config.ini"),
"meson_cross_file": str(TOOLS_DIR / "emscripten.meson.cross"),
# Rust-specific configuration
"rustflags": "-C link-arg=-sSIDE_MODULE=2 -C link-arg=-sWASM_BIGINT -Z link-native-libraries=no",
Expand All @@ -213,8 +212,9 @@ def to_env(self) -> dict[str, str]:
"cxxflags": "$(CXXFLAGS_BASE)",
"ldflags": "$(LDFLAGS_BASE) -s SIDE_MODULE=1",
# Rust-specific configuration
"pyo3_cross_lib_dir": "$(CPYTHONINSTALL)/lib",
"pyo3_cross_lib_dir": "$(CPYTHONINSTALL)/sysconfigdata", # FIXME: pyodide xbuildenv stores sysconfigdata here
"pyo3_cross_include_dir": "$(PYTHONINCLUDE)",
"pyo3_cross_python_version": "$(PYMAJOR).$(PYMINOR)",
# Misc
"stdlib_module_cflags": "$(CFLAGS_BASE) -I$(PYTHONINCLUDE) -I Include/ -I. -IInclude/internal/", # TODO: remove this
# Paths to build dependencies
Expand Down
7 changes: 0 additions & 7 deletions pyodide_build/tools/pyo3_config.ini

This file was deleted.

0 comments on commit f3f6b21

Please sign in to comment.