Skip to content

Commit 57ea2e1

Browse files
committed
Follow Maturin
1 parent b2cf028 commit 57ea2e1

File tree

3 files changed

+22
-64
lines changed

3 files changed

+22
-64
lines changed

crates/uv-distribution-types/src/prioritized_distribution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ fn implied_platform_markers(filename: &WheelFilename) -> MarkerTree {
902902
tag_marker.and(MarkerTree::expression(MarkerExpression::String {
903903
key: MarkerValueString::PlatformMachine,
904904
operator: MarkerOperator::Equal,
905-
value: ArcStr::from(arch.linux_name()),
905+
value: ArcStr::from(arch.name()),
906906
}));
907907
marker.or(tag_marker);
908908
}

crates/uv-platform-tags/src/platform.rs

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl Arch {
197197
}
198198
}
199199

200-
/// Returns the standard name of the architecture in the Linux world.
200+
/// Returns the standard name of the architecture.
201201
pub fn name(&self) -> &'static str {
202202
match self {
203203
Self::Aarch64 => "aarch64",
@@ -216,64 +216,22 @@ impl Arch {
216216
}
217217
}
218218

219-
/// Returns the standard name of the architecture in the FreeBSD world, if it differs from the
220-
/// Linux name.
221-
pub fn freebsd_name(&self) -> Option<&'static str> {
219+
/// Represents the hardware platform.
220+
///
221+
/// This is the same as the native platform's `uname -m` output.
222+
///
223+
/// Based on: <https://github.com/PyO3/maturin/blob/8ab42219247277fee513eac753a3e90e76cd46b9/src/target/mod.rs#L131>
224+
pub fn machine(&self) -> &'static str {
222225
match self {
223-
Self::Aarch64 => None,
224-
Self::Armv5TEL => Some("armv5"),
225-
Self::Armv6L => Some("armv6"),
226-
Self::Armv7L => Some("armv7"),
227-
Self::Powerpc64Le => Some("powerpc64le"),
228-
Self::Powerpc64 => Some("powerpc64"),
229-
Self::Powerpc => Some("powerpc"),
230-
Self::X86 => Some("i386"),
231-
Self::X86_64 => Some("amd64"),
232-
Self::S390X => None,
233-
Self::LoongArch64 => None,
234-
Self::Riscv64 => None,
235-
Self::Wasm32 => None,
236-
}
237-
}
238-
239-
/// Returns the standard name of the architecture in the NetBSD world, if it differs from the
240-
/// Linux name.
241-
pub fn netbsd_name(&self) -> Option<&'static str> {
242-
match self {
243-
Self::Aarch64 => None,
244-
Self::Armv5TEL => Some("armv5"),
245-
Self::Armv6L => Some("armv6"),
246-
Self::Armv7L => Some("armv7"),
247-
Self::Powerpc64Le => Some("powerpc64le"),
248-
Self::Powerpc64 => Some("powerpc64"),
249-
Self::Powerpc => Some("powerpc"),
250-
Self::X86 => Some("i386"),
251-
Self::X86_64 => Some("amd64"),
252-
Self::S390X => None,
253-
Self::LoongArch64 => None,
254-
Self::Riscv64 => None,
255-
Self::Wasm32 => None,
256-
}
257-
}
258-
259-
260-
/// Returns the standard name of the architecture in the FreeBSD world, if it differs from the
261-
/// Linux name.
262-
pub fn openbsd_name(&self) -> Option<&'static str> {
263-
match self {
264-
Self::Aarch64 => Some("arm64"),
265-
Self::Armv5TEL => Some("armv5"),
266-
Self::Armv6L => Some("armv6"),
267-
Self::Armv7L => Some("armv7"),
268-
Self::Powerpc64Le => Some("powerpc64le"),
269-
Self::Powerpc64 => Some("powerpc64"),
270-
Self::Powerpc => Some("powerpc"),
271-
Self::X86 => Some("i386"),
272-
Self::X86_64 => Some("amd64"),
273-
Self::S390X => None,
274-
Self::LoongArch64 => None,
275-
Self::Riscv64 => None,
276-
Self::Wasm32 => None,
226+
Arch::Aarch64 => "arm64",
227+
Arch::Armv5TEL | Arch::Armv6L | Arch::Armv7L => "arm",
228+
Arch::Powerpc | Arch::Powerpc64Le | Arch::Powerpc64 => "powerpc",
229+
Arch::X86 => "i386",
230+
Arch::X86_64 => "amd64",
231+
Arch::Riscv64 => "riscv",
232+
Arch::Wasm32 => "wasm32",
233+
Arch::S390X => "s390x",
234+
Arch::LoongArch64 => "loongarch64",
277235
}
278236
}
279237
}

crates/uv-platform-tags/src/tags.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,23 +554,23 @@ fn compatible_tags(platform: &Platform) -> Result<Vec<PlatformTag>, PlatformErro
554554
(Os::Windows, Arch::Aarch64) => vec![PlatformTag::WinArm64],
555555
(Os::FreeBsd { release }, arch) => {
556556
let release_tag = release.replace(['.', '-'], "_").to_lowercase();
557-
let arch_tag = arch.freebsd_name().unwrap_or(arch.name());
557+
let arch_tag = arch.machine();
558558
let release_arch = format!("{release_tag}_{arch_tag}");
559559
vec![PlatformTag::FreeBsd {
560560
release_arch: SmallString::from(release_arch),
561561
}]
562562
}
563563
(Os::NetBsd { release }, arch) => {
564-
let release_tag = release.replace(['.', '-'], "_").to_lowercase();
565-
let arch_tag = arch.netbsd_name().unwrap_or(arch.name());
564+
let release_tag = release.replace(['.', '-'], "_");
565+
let arch_tag = arch.machine();
566566
let release_arch = format!("{release_tag}_{arch_tag}");
567567
vec![PlatformTag::NetBsd {
568568
release_arch: SmallString::from(release_arch),
569569
}]
570570
}
571571
(Os::OpenBsd { release }, arch) => {
572-
let release_tag = release.replace(['.', '-'], "_").to_lowercase();
573-
let arch_tag = arch.openbsd_name().unwrap_or(arch.name());
572+
let release_tag = release.replace(['.', '-'], "_");
573+
let arch_tag = arch.machine();
574574
let release_arch = format!("{release_tag}_{arch_tag}");
575575
vec![PlatformTag::OpenBsd {
576576
release_arch: SmallString::from(release_arch),

0 commit comments

Comments
 (0)