Skip to content

Commit

Permalink
Allow overriding platform release version using env var
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jun 20, 2022
1 parent 0ea3785 commit 7642d0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
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
* 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

Expand Down
29 changes: 23 additions & 6 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(),
Expand Down Expand Up @@ -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<String> {
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 {
Expand Down

0 comments on commit 7642d0a

Please sign in to comment.