Skip to content

Commit

Permalink
Fix mac os arch with platform.mac_ver() (#2454)
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Mar 14, 2024
1 parent ef22e9b commit b5d9014
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/platform-tags/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum Arch {
Armv7L,
Powerpc64Le,
Powerpc64,
#[serde(alias = "i386")]
X86,
#[serde(alias = "amd64")]
X86_64,
Expand Down
23 changes: 16 additions & 7 deletions crates/uv-interpreter/python/get_interpreter_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
The script will exit with status 0 on known error that are turned into rust errors.
"""

import sys

import json
import os
import platform
import sys
import struct
import sysconfig


Expand Down Expand Up @@ -451,13 +453,20 @@ def get_operating_system_and_architecture():
"name": "windows",
}
elif operating_system == "macosx":
# GitHub Actions python seems to be doing this.
if architecture == "universal2":
if platform.processor() == "arm":
architecture = "aarch64"
# Apparently, Mac OS is reporting i386 sometimes in sysconfig.get_platform even
# though that's not a thing anymore.
# https://github.com/astral-sh/uv/issues/2450
version, _, architecture = platform.mac_ver()

# https://github.com/pypa/packaging/blob/cc938f984bbbe43c5734b9656c9837ab3a28191f/src/packaging/tags.py#L356-L363
is_32bit = struct.calcsize("P") == 4
if is_32bit:
if architecture.startswith("ppc"):
architecture = "ppc"
else:
architecture = platform.processor()
version = platform.mac_ver()[0].split(".")
architecture = "i386"

version = version.split(".")
operating_system = {
"name": "macos",
"major": int(version[0]),
Expand Down

0 comments on commit b5d9014

Please sign in to comment.