Skip to content

Commit

Permalink
Add support for Illumos
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Nov 29, 2021
1 parent 6fc4f9f commit d8110ff
Show file tree
Hide file tree
Showing 6 changed files with 784 additions and 27 deletions.
37 changes: 14 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ flate2 = "1.0.18"
goblin = "0.4.3"
human-panic = { version = "1.0.3", optional = true }
keyring = { version = "0.10.4", optional = true }
platform-info = "0.1.0"
platform-info = "0.2.0"
pretty_env_logger = { version = "0.4.0", optional = true }
regex = "1.4.5"
reqwest = { version = "0.11.2", optional = true, default-features = false, features = ["blocking", "multipart"] }
Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
wheels on linux in [#709](https://github.com/PyO3/maturin/pull/709)
* Revert back to Rust 2018 edition in [#710](https://github.com/PyO3/maturin/pull/710)
* Warn missing `cffi` package dependency in [#711](https://github.com/PyO3/maturin/pull/711)
* Add support for Illumos in [#712](https://github.com/PyO3/maturin/pull/712)

## [0.12.2] - 2021-11-26

Expand Down
5 changes: 3 additions & 2 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ impl PythonInterpreter {
pub fn get_tag(&self, platform_tag: PlatformTag, universal2: bool) -> String {
// Restrict `sysconfig.get_platform()` usage to Windows and non-portable Linux only for now
// so we don't need to deal with macOS deployment target
let use_sysconfig_platform =
self.target.is_windows() || (self.target.is_linux() && !platform_tag.is_portable());
let use_sysconfig_platform = self.target.is_windows()
|| (self.target.is_linux() && !platform_tag.is_portable())
|| self.target.is_illumos();
let platform = if use_sysconfig_platform {
self.platform
.clone()
Expand Down
46 changes: 45 additions & 1 deletion src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum Os {
FreeBsd,
NetBsd,
OpenBsd,
Illumos,
}

impl fmt::Display for Os {
Expand All @@ -31,6 +32,7 @@ impl fmt::Display for Os {
Os::FreeBsd => write!(f, "FreeBSD"),
Os::NetBsd => write!(f, "NetBSD"),
Os::OpenBsd => write!(f, "OpenBSD"),
Os::Illumos => write!(f, "Illumos"),
}
}
}
Expand Down Expand Up @@ -83,6 +85,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> {
Arch::X86_64,
],
Os::OpenBsd => vec![Arch::X86, Arch::X86_64, Arch::Aarch64],
Os::Illumos => vec![Arch::X86, Arch::X86_64],
}
}

Expand Down Expand Up @@ -123,6 +126,7 @@ impl Target {
target_lexicon::OperatingSystem::Netbsd => Os::NetBsd,
target_lexicon::OperatingSystem::Freebsd => Os::FreeBsd,
target_lexicon::OperatingSystem::Openbsd => Os::OpenBsd,
target_lexicon::OperatingSystem::Illumos => Os::Illumos,
unsupported => bail!("The operating system {:?} is not supported", unsupported),
};

Expand Down Expand Up @@ -190,6 +194,40 @@ impl Target {
arch
)
}
(Os::Illumos, Arch::X86)
| (Os::Illumos, Arch::X86_64) => {
let info = match PlatformInfo::new() {
Ok(info) => info,
Err(error) => panic!("{}", error),
};
let mut release = info.release().replace(".", "_").replace("-", "_");
let mut arch = info.machine().replace(' ', "_").replace('/', "_");

let mut os = self.os.to_string().to_ascii_lowercase();
// See https://github.com/python/cpython/blob/46c8d915715aa2bd4d697482aa051fe974d440e1/Lib/sysconfig.py#L722-L730
if let Some((major, other)) = release.split_once('_') {
let major_ver: u64 = major.parse().expect("illumos major version is not a number");
if major_ver >= 5 {
// SunOS 5 == Solaris 2
os = "solaris".to_string();
release = format!("{}_{}", major_ver - 3, other);
let bitness = match self.arch {
Arch::X86_64 => "64bit".to_string(),
Arch::X86 => "32bit".to_string(),
_ => panic!(
"unsupported architecture should not have reached get_platform_tag()"
),
};
arch = format!("{}_{}", arch, bitness);
}
}
format!(
"{}_{}_{}",
os,
release,
arch
)
}
(Os::Linux, _) => {
let arch = if self.cross_compiling {
self.arch.to_string()
Expand Down Expand Up @@ -234,6 +272,7 @@ impl Target {
Os::FreeBsd => "freebsd",
Os::NetBsd => "netbsd",
Os::OpenBsd => "openbsd",
Os::Illumos => "sunos",
}
}

Expand Down Expand Up @@ -269,7 +308,7 @@ impl Target {
pub fn is_unix(&self) -> bool {
match self.os {
Os::Windows => false,
Os::Linux | Os::Macos | Os::FreeBsd | Os::NetBsd | Os::OpenBsd => true,
Os::Linux | Os::Macos | Os::FreeBsd | Os::NetBsd | Os::OpenBsd | Os::Illumos => true,
}
}

Expand Down Expand Up @@ -298,6 +337,11 @@ impl Target {
self.os == Os::Windows
}

/// Returns true if the current platform is illumos
pub fn is_illumos(&self) -> bool {
self.os == Os::Illumos
}

/// Returns true if the current platform's target env is Musl
pub fn is_musl_target(&self) -> bool {
matches!(
Expand Down
Loading

0 comments on commit d8110ff

Please sign in to comment.