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

Always use EXT_SUFFIX from sysconfig #498

Merged
merged 1 commit into from
Apr 12, 2021
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
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