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

Add support for GNU/Hurd #2306

Merged
merged 1 commit into from
Nov 17, 2024
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 @@ -4,6 +4,7 @@

* Improve wheel reproducibility by sorting external libraries [#2261](https://github.com/PyO3/maturin/pull/2261)
* Fix Readme and pyproject.toml inclusions for workspace where the bindings crate is not in the root in [#2262](https://github.com/PyO3/maturin/pull/2262)
* Add support for GNU/Hurd target in [#2306](https://github.com/PyO3/maturin/pull/2306)

## [1.7.4]

Expand Down
2 changes: 1 addition & 1 deletion src/python_interpreter/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl InterpreterConfig {
InterpreterKind::GraalPy => abi_tag.unwrap_or_else(|| GRAALPY_ABI_TAG.to_string()),
};
let file_ext = if target.is_windows() { "pyd" } else { "so" };
let ext_suffix = if target.is_linux() || target.is_macos() {
let ext_suffix = if target.is_linux() || target.is_macos() || target.is_hurd() {
let target_env = target.get_python_target_env(interpreter_kind, (major, minor));
match interpreter_kind {
InterpreterKind::CPython => ext_suffix.unwrap_or_else(|| {
Expand Down
3 changes: 2 additions & 1 deletion src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ impl PythonInterpreter {
let target = &context.target;
let use_sysconfig_platform = target.is_windows()
|| (target.is_linux() && platform_tags.iter().any(|tag| !tag.is_portable()))
|| target.is_illumos();
|| target.is_illumos()
|| target.is_hurd();
let platform = if use_sysconfig_platform {
if let Some(platform) = self.platform.clone() {
platform
Expand Down
14 changes: 13 additions & 1 deletion src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum Os {
Emscripten,
Wasi,
Aix,
Hurd,
}

impl fmt::Display for Os {
Expand All @@ -54,6 +55,7 @@ impl fmt::Display for Os {
Os::Emscripten => write!(f, "Emscripten"),
Os::Wasi => write!(f, "Wasi"),
Os::Aix => write!(f, "AIX"),
Os::Hurd => write!(f, "Hurd"),
}
}
}
Expand Down Expand Up @@ -193,6 +195,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> {
Os::Solaris => vec![Arch::X86_64, Arch::Sparc64],
Os::Emscripten | Os::Wasi => vec![Arch::Wasm32],
Os::Aix => vec![Arch::Powerpc64],
Os::Hurd => vec![Arch::X86, Arch::X86_64],
}
}

Expand Down Expand Up @@ -255,6 +258,7 @@ impl Target {
OperatingSystem::Emscripten => Os::Emscripten,
OperatingSystem::Wasi | OperatingSystem::WasiP1 | OperatingSystem::WasiP2 => Os::Wasi,
OperatingSystem::Aix => Os::Aix,
OperatingSystem::Hurd => Os::Hurd,
unsupported => bail!("The operating system {:?} is not supported", unsupported),
};

Expand Down Expand Up @@ -426,6 +430,7 @@ impl Target {
// This isn't real, there's no sys.platform here
Os::Wasi => "wasi",
Os::Aix => "aix",
Os::Hurd => "gnu0",
}
}

Expand Down Expand Up @@ -510,7 +515,8 @@ impl Target {
| Os::Haiku
| Os::Emscripten
| Os::Wasi
| Os::Aix => true,
| Os::Aix
| Os::Hurd => true,
}
}

Expand Down Expand Up @@ -586,6 +592,12 @@ impl Target {
self.os == Os::Wasi
}

/// Returns true if we're building a binary for GNU/Hurd
#[inline]
pub fn is_hurd(&self) -> bool {
self.os == Os::Hurd
}

/// Returns true if the current platform's target env is Musl
#[inline]
pub fn is_musl_libc(&self) -> bool {
Expand Down
Loading
Loading