Skip to content

Commit

Permalink
Always use EXT_SUFFIX from sysconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Apr 12, 2021
1 parent 3e4f390 commit b8de00b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 65 deletions.
48 changes: 8 additions & 40 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,46 +404,14 @@ impl PythonInterpreter {
///
/// For pypy3, we read importlib.machinery.EXTENSION_SUFFIXES[0].
pub fn get_library_name(&self, base: &str) -> String {
match self.interpreter_kind {
InterpreterKind::CPython => {
let platform = self.target.get_shared_platform_tag();

if platform.is_empty() {
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,
major = self.major,
minor = self.minor,
abiflags = self.abiflags,
platform = platform,
)
} else {
format!(
"{base}.cp{major}{minor}-{platform}.pyd",
base = base,
major = self.major,
minor = self.minor,
platform = platform
)
}
}
InterpreterKind::PyPy => format!(
"{base}{ext_suffix}",
base = base,
ext_suffix = self
.ext_suffix
.clone()
.expect("PyPy's syconfig didn't define an `EXT_SUFFIX` ಠ_ಠ")
),
}
format!(
"{base}{ext_suffix}",
base = base,
ext_suffix = self
.ext_suffix
.clone()
.expect("syconfig didn't define an `EXT_SUFFIX` ಠ_ಠ")
)
}

/// Checks whether the given command is a python interpreter and returns a
Expand Down
25 changes: 0 additions & 25 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,6 @@ impl Target {
}
}

/// Returns the platform for the tag in the shared libraries file name
pub fn get_shared_platform_tag(&self) -> &'static str {
match (&self.os, &self.arch) {
(Os::FreeBsd, _) => "", // according imp.get_suffixes(), there are no such
(Os::OpenBsd, _) => "", // according imp.get_suffixes(), there are no such
(Os::Linux, Arch::Aarch64) => "aarch64-linux-gnu", // aka armv8-linux-gnueabihf
(Os::Linux, Arch::Armv7L) => "arm-linux-gnueabihf",
(Os::Linux, Arch::Powerpc64) => "powerpc64-linux-gnu",
(Os::Linux, Arch::Powerpc64Le) => "powerpc64le-linux-gnu",
(Os::Linux, Arch::X86) => "i386-linux-gnu", // not i686
(Os::Linux, Arch::X86_64) => "x86_64-linux-gnu",
(Os::Linux, Arch::S390X) => "s390x-linux-gnu",
(Os::Macos, Arch::X86_64) => "darwin",
(Os::Macos, Arch::Aarch64) => "darwin",
(Os::Windows, Arch::X86) => "win32",
(Os::Windows, Arch::X86_64) => "win_amd64",
(Os::Macos, _) => {
panic!("unsupported macOS Arch should not have reached get_shared_platform_tag()")
}
(Os::Windows, _) => {
panic!("unsupported Windows Arch should not have reached get_shared_platform_tag()")
}
}
}

/// Returns the name python uses in `sys.platform` for this os
pub fn get_python_os(&self) -> &str {
match self.os {
Expand Down

0 comments on commit b8de00b

Please sign in to comment.