From d4726f23052f0b3e7569c3e3ecf97da2d9207ab0 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 17 Feb 2023 12:18:32 +0800 Subject: [PATCH 1/2] refactor: Add `emscripten_verison` function --- src/target.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/target.rs b/src/target.rs index e7641b8e0..9a24758a6 100644 --- a/src/target.rs +++ b/src/target.rs @@ -330,12 +330,7 @@ impl Target { } // Emscripten (Os::Emscripten, Arch::Wasm32) => { - let os_version = env::var("MATURIN_EMSCRIPTEN_VERSION"); - let release = match os_version { - Ok(os_ver) => os_ver, - Err(_) => emcc_version()?, - }; - let release = release.replace(['.', '-'], "_"); + let release = emscripten_version()?.replace(['.', '-'], "_"); format!("emscripten_{release}_wasm32") } (Os::Wasi, Arch::Wasm32) => { @@ -783,6 +778,16 @@ pub(crate) fn rustc_macosx_target_version(target: &str) -> (u16, u16) { rustc_target_version().unwrap_or(fallback_version) } +/// Emscripten version +fn emscripten_version() -> Result { + let os_version = env::var("MATURIN_EMSCRIPTEN_VERSION"); + let release = match os_version { + Ok(os_ver) => os_ver, + Err(_) => emcc_version()?, + }; + Ok(release) +} + fn emcc_version() -> Result { use regex::bytes::Regex; use std::process::Command; From 03f01f5a866133e873124d9a22afc059d9d85063 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 17 Feb 2023 12:21:05 +0800 Subject: [PATCH 2/2] Use default `ext_suffix` for Emscripten target if not provided in `PYO3_CONFIG_FILE` --- Changelog.md | 1 + src/python_interpreter/config.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Changelog.md b/Changelog.md index e3e928bcd..03174967f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add support for custom TLS certificate authority bundle in [#1483](https://github.com/PyO3/maturin/pull/1483) * Add support for Emscripten in `generate-ci` command in [#1484](https://github.com/PyO3/maturin/pull/1484) * Add support for linking with pyo3 in abi3 debug mode on Windows in [#1487](https://github.com/PyO3/maturin/pull/1487) +* Use default `ext_suffix` for Emscripten target if not provided in `PYO3_CONFIG_FILE` in [#1491](https://github.com/PyO3/maturin/pull/1491) ## [0.14.13] - 2023-02-12 diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs index 4473f7e8e..feec2848a 100644 --- a/src/python_interpreter/config.rs +++ b/src/python_interpreter/config.rs @@ -198,6 +198,16 @@ impl InterpreterConfig { ) }), } + } else if target.is_emscripten() && matches!(interpreter_kind, InterpreterKind::CPython) { + ext_suffix.unwrap_or_else(|| { + format!( + ".cpython-{}-{}-{}.{}", + abi_tag, + target.get_python_arch(), + target.get_python_os(), + file_ext + ) + }) } else { ext_suffix.context("missing value for ext_suffix")? };