diff --git a/Changelog.md b/Changelog.md index d8cca60fe..c69b3eae7 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 * Infer target triple from `ARCHFLAGS` for macOS to be compatible with `cibuildwheel` in [#967](https://github.com/PyO3/maturin/pull/967) * Expose commonly used Cargo CLI options in `maturin build` command in [#972](https://github.com/PyO3/maturin/pull/972) * Add support for `wasm32-unknown-emscripten` target in [#974](https://github.com/PyO3/maturin/pull/974) +* Allow overriding platform release version using env var in [#975](https://github.com/PyO3/maturin/pull/975) ## [0.12.20] - 2022-06-15 diff --git a/src/target.rs b/src/target.rs index 878cf1968..55709af87 100644 --- a/src/target.rs +++ b/src/target.rs @@ -209,8 +209,7 @@ impl Target { | (Os::OpenBsd, Arch::X86) | (Os::OpenBsd, Arch::X86_64) | (Os::OpenBsd, Arch::Aarch64) => { - let info = PlatformInfo::new()?; - let release = info.release().replace('.', "_").replace('-', "_"); + let release = self.get_platform_release()?; let arch = match self.arch { Arch::X86_64 => "amd64", Arch::X86 => "i386", @@ -232,8 +231,7 @@ impl Target { (Os::Dragonfly, Arch::X86_64) // Haiku | (Os::Haiku, Arch::X86_64) => { - let info = PlatformInfo::new()?; - let release = info.release().replace('.', "_").replace('-', "_"); + let release = self.get_platform_release()?; format!( "{}_{}_{}", self.os.to_string().to_ascii_lowercase(), @@ -320,14 +318,33 @@ impl Target { (Os::Windows, Arch::Aarch64) => "win_arm64".to_string(), // Emscripten (Os::Emscripten, Arch::Wasm32) => { - let version = emcc_version()?; - format!("emscripten_{}_wasm32", version.replace('.', "_")) + 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('.', "_").replace('-', "_"); + format!("emscripten_{}_wasm32", release) } (_, _) => panic!("unsupported target should not have reached get_platform_tag()"), }; Ok(tag) } + fn get_platform_release(&self) -> Result { + let os = self.os.to_string(); + let os_version = env::var(format!("MATURIN_{}_VERSION", os.to_ascii_uppercase())); + let release = match os_version { + Ok(os_ver) => os_ver, + Err(_) => { + let info = PlatformInfo::new()?; + info.release().to_string() + } + }; + let release = release.replace('.', "_").replace('-', "_"); + Ok(release) + } + /// Returns the name python uses in `sys.platform` for this architecture. pub fn get_python_arch(&self) -> &str { match self.arch {