diff --git a/.cirrus.yml b/.cirrus.yml index 63b22ba43..def1b705d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,9 @@ freebsd_instance: image: freebsd-12-0-release-amd64 +env: + RUST_BACKTRACE: 1 + freebsd_task: name: $TOOLCHAIN x86_64-unknown-freebsd env: @@ -12,3 +15,5 @@ freebsd_task: - sh rustup.sh -y --default-toolchain $TOOLCHAIN build_script: - $HOME/.cargo/bin/rustup run $TOOLCHAIN cargo build + test_script: + - $HOME/.cargo/bin/rustup run $TOOLCHAIN cargo test --features skip-nightly-tests diff --git a/Cargo.lock b/Cargo.lock index 884c59789..ae9b4aae5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1058,6 +1058,15 @@ name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "platform-info" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "platforms" version = "0.2.0" @@ -1127,6 +1136,7 @@ dependencies = [ "human-panic 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "indoc 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "keyring 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "platform-info 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2257,6 +2267,7 @@ dependencies = [ "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +"checksum platform-info 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f2fd076acdc7a98374de6e300bf3af675997225bef21aecac2219553f04dd7e8" "checksum platforms 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cfec0daac55b13af394ceaaad095d17c790f77bdc9329264f06e49d6cd3206c" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" diff --git a/Cargo.toml b/Cargo.toml index 9cd4541b8..a9c0ff57e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ cbindgen = { version = "0.9.0", default-features = false } walkdir = "2.2.8" flate2 = "1.0.9" tar = "0.4.26" +platform-info = "0.0.1" [dev-dependencies] indoc = "0.3.3" diff --git a/src/get_interpreter_metadata.py b/src/get_interpreter_metadata.py index 99afbe5a2..ef7fb9ec8 100644 --- a/src/get_interpreter_metadata.py +++ b/src/get_interpreter_metadata.py @@ -14,7 +14,7 @@ "u": sysconfig.get_config_var("Py_UNICODE_SIZE") == 4, "d": sysconfig.get_config_var("Py_DEBUG") == 1, # This one isn't technically necessary, but still very useful for sanity checks - "platform": sys.platform, + "platform": platform.system().lower(), } print(json.dumps(metadata)) diff --git a/src/python_interpreter.rs b/src/python_interpreter.rs index 473dec58f..53b3cb481 100644 --- a/src/python_interpreter.rs +++ b/src/python_interpreter.rs @@ -277,8 +277,8 @@ pub struct PythonInterpreter { /// /// See PEP 261 and PEP 393 for details pub abiflags: String, - /// Currently just the value of [Target::os()], i.e. "windows", "linux" or - /// "macos" + /// Currently just the value of [Target::os()], i.e. "windows", "linux", + /// "macos" or "freebsd" pub target: Target, /// Path to the python interpreter, e.g. /usr/bin/python3.6 /// @@ -305,9 +305,10 @@ fn fun_with_abiflags( target: &Target, ) -> Result { let sane_platform = match message.platform.as_ref() { - "win32" | "win_amd64" => target.is_windows(), - "linux" | "linux2" | "linux3" => target.is_linux(), + "windows" => target.is_windows(), + "linux" => target.is_linux(), "darwin" => target.is_macos(), + "freebsd" => target.is_freebsd(), _ => false, }; @@ -420,6 +421,7 @@ impl PythonInterpreter { /// Linux: steinlaus.cpython-35m-x86_64-linux-gnu.so /// Windows: steinlaus.cp35-win_amd64.pyd /// Mac: steinlaus.cpython-35m-darwin.so + /// FreeBSD: steinlaus.cpython-35m.so /// /// For pypy3, we read sysconfig.get_config_var("EXT_SUFFIX"). /// @@ -430,7 +432,15 @@ impl PythonInterpreter { Interpreter::CPython => { let platform = self.target.get_shared_platform_tag(); - if self.target.is_unix() { + if self.target.is_freebsd() { + format!( + "{base}.cpython-{major}{minor}{abiflags}.so", + base = base, + major = self.major, + minor = self.minor, + abiflags = self.abiflags, + ) + } else if self.target.is_unix() { format!( "{base}.cpython-{major}{minor}{abiflags}-{platform}.so", base = base, diff --git a/src/target.rs b/src/target.rs index 9b63bb9b3..4a63186e3 100644 --- a/src/target.rs +++ b/src/target.rs @@ -1,4 +1,5 @@ use failure::{bail, format_err, Error}; +use platform_info::*; use platforms; use platforms::target::Arch; use serde::{Deserialize, Serialize}; @@ -14,6 +15,7 @@ enum OS { Linux, Windows, Macos, + FreeBSD, } /// Decides how to handle manylinux compliance @@ -60,6 +62,7 @@ impl Target { "linux" => OS::Linux, "windows" => OS::Windows, "macos" => OS::Macos, + "freebsd" => OS::FreeBSD, unsupported => panic!("The platform {} is not supported", unsupported), }; @@ -89,6 +92,7 @@ impl Target { platforms::target::OS::Linux => OS::Linux, platforms::target::OS::Windows => OS::Windows, platforms::target::OS::MacOS => OS::Macos, + platforms::target::OS::FreeBSD => OS::FreeBSD, unsupported => bail!("The operating system {:?} is not supported", unsupported), }; @@ -120,6 +124,11 @@ impl Target { self.os == OS::Linux } + /// Returns true if the current platform is freebsd + pub fn is_freebsd(&self) -> bool { + self.os == OS::FreeBSD + } + /// Returns true if the current platform is mac os pub fn is_macos(&self) -> bool { self.os == OS::Macos @@ -131,22 +140,35 @@ impl Target { } /// Returns the platform part of the tag for the wheel name for cffi wheels - pub fn get_platform_tag(&self, manylinux: &Manylinux) -> &'static str { + pub fn get_platform_tag(&self, manylinux: &Manylinux) -> String { match (&self.os, self.is_64_bit, manylinux) { - (&OS::Linux, true, Manylinux::Off) => "linux_x86_64", - (&OS::Linux, false, Manylinux::Off) => "linux_i686", - (&OS::Linux, true, Manylinux::Manylinux1) => "manylinux1_x86_64", - (&OS::Linux, true, Manylinux::Manylinux1Unchecked) => "manylinux1_x86_64", - (&OS::Linux, true, Manylinux::Manylinux2010) => "manylinux2010_x86_64", - (&OS::Linux, true, Manylinux::Manylinux2010Unchecked) => "manylinux2010_x86_64", - (&OS::Linux, false, Manylinux::Manylinux1) => "manylinux1_i686", - (&OS::Linux, false, Manylinux::Manylinux1Unchecked) => "manylinux1_i686", - (&OS::Linux, false, Manylinux::Manylinux2010) => "manylinux2010_i686", - (&OS::Linux, false, Manylinux::Manylinux2010Unchecked) => "manylinux2010_i686", - (&OS::Windows, true, _) => "win_amd64", - (&OS::Windows, false, _) => "win32", - (&OS::Macos, true, _) => "macosx_10_7_x86_64", + (&OS::Linux, true, Manylinux::Off) => "linux_x86_64".to_string(), + (&OS::Linux, false, Manylinux::Off) => "linux_i686".to_string(), + (&OS::Linux, true, Manylinux::Manylinux1) => "manylinux1_x86_64".to_string(), + (&OS::Linux, true, Manylinux::Manylinux1Unchecked) => "manylinux1_x86_64".to_string(), + (&OS::Linux, true, Manylinux::Manylinux2010) => "manylinux2010_x86_64".to_string(), + (&OS::Linux, true, Manylinux::Manylinux2010Unchecked) => { + "manylinux2010_x86_64".to_string() + } + (&OS::Linux, false, Manylinux::Manylinux1) => "manylinux1_i686".to_string(), + (&OS::Linux, false, Manylinux::Manylinux1Unchecked) => "manylinux1_i686".to_string(), + (&OS::Linux, false, Manylinux::Manylinux2010) => "manylinux2010_i686".to_string(), + (&OS::Linux, false, Manylinux::Manylinux2010Unchecked) => { + "manylinux2010_i686".to_string() + } + (&OS::Windows, true, _) => "win_amd64".to_string(), + (&OS::Windows, false, _) => "win32".to_string(), + (&OS::Macos, true, _) => "macosx_10_7_x86_64".to_string(), (&OS::Macos, false, _) => panic!("32-bit wheels are not supported for mac os"), + (&OS::FreeBSD, true, _) => { + let info = match PlatformInfo::new() { + Ok(info) => info, + Err(error) => panic!(error), + }; + let release = info.release().replace(".", "_").replace("-", "_"); + format!("freebsd_{}_amd64", release) + } + (&OS::FreeBSD, false, _) => panic!("32-bit wheels are not supported for FreeBSD"), } } @@ -169,6 +191,7 @@ impl Target { } } OS::Macos => "darwin", + OS::FreeBSD => "", // according imp.get_suffixes(), there are no such OS::Windows => { if self.is_64_bit { "win_amd64"