Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default ext_suffix for Emscripten target if not provided in PYO3_CONFIG_FILE #1491

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/python_interpreter/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?
};
Expand Down
17 changes: 11 additions & 6 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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<String> {
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<String> {
use regex::bytes::Regex;
use std::process::Command;
Expand Down