File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,10 +81,37 @@ function getPlatform(): string {
8181 if ( os === "darwin" ) {
8282 return "darwin-aarch64" ; // Intel Macs use Rosetta
8383 } else if ( os === "linux" ) {
84+ // Detect architecture
85+ let arch_str : string ;
8486 if ( cpu === "x64" ) {
85- return "linux-x86_64" ;
87+ arch_str = "x86_64" ;
88+ } else if ( cpu === "arm64" ) {
89+ arch_str = "aarch64" ;
90+ } else {
91+ throw new Pg0NotFoundError ( `Unsupported Linux architecture: ${ cpu } ` ) ;
8692 }
87- throw new Pg0NotFoundError ( `Unsupported Linux architecture: ${ cpu } ` ) ;
93+
94+ // Detect libc (musl vs glibc)
95+ // Check for musl by looking for the musl loader
96+ const { execSync } = require ( "child_process" ) ;
97+ try {
98+ const ldd = execSync ( "ldd --version 2>&1" , { encoding : "utf-8" } ) ;
99+ if ( ldd . toLowerCase ( ) . includes ( "musl" ) ) {
100+ return `linux-${ arch_str } -musl` ;
101+ }
102+ } catch {
103+ // If ldd fails, check for musl loader file
104+ const { existsSync } = require ( "fs" ) ;
105+ if (
106+ existsSync ( `/lib/ld-musl-${ arch_str } .so.1` ) ||
107+ existsSync ( `/lib/ld-musl-x86_64.so.1` ) ||
108+ existsSync ( `/lib/ld-musl-aarch64.so.1` )
109+ ) {
110+ return `linux-${ arch_str } -musl` ;
111+ }
112+ }
113+ // Default to glibc
114+ return `linux-${ arch_str } -gnu` ;
88115 } else if ( os === "win32" ) {
89116 return "windows-x86_64" ;
90117 }
Original file line number Diff line number Diff line change @@ -104,10 +104,42 @@ def _get_platform() -> str:
104104 # macOS - only Apple Silicon supported, Intel uses Rosetta
105105 return "darwin-aarch64"
106106 elif system == "linux" :
107+ # Detect architecture
107108 if machine in ("x86_64" , "amd64" ):
108- return "linux-x86_64"
109+ arch_str = "x86_64"
110+ elif machine in ("aarch64" , "arm64" ):
111+ arch_str = "aarch64"
109112 else :
110113 raise Pg0NotFoundError (f"Unsupported Linux architecture: { machine } " )
114+
115+ # Detect libc (musl vs glibc)
116+ # Check for musl by looking for the musl loader
117+ import subprocess
118+ try :
119+ result = subprocess .run (
120+ ["ldd" , "--version" ],
121+ capture_output = True ,
122+ text = True ,
123+ timeout = 5 ,
124+ )
125+ output = result .stdout + result .stderr
126+ if "musl" in output .lower ():
127+ return f"linux-{ arch_str } -musl"
128+ except (FileNotFoundError , subprocess .TimeoutExpired ):
129+ pass
130+
131+ # Check for musl loader file
132+ musl_loaders = [
133+ f"/lib/ld-musl-{ arch_str } .so.1" ,
134+ "/lib/ld-musl-x86_64.so.1" ,
135+ "/lib/ld-musl-aarch64.so.1" ,
136+ ]
137+ for loader in musl_loaders :
138+ if Path (loader ).exists ():
139+ return f"linux-{ arch_str } -musl"
140+
141+ # Default to glibc
142+ return f"linux-{ arch_str } -gnu"
111143 elif system == "windows" :
112144 return "windows-x86_64"
113145 else :
You can’t perform that action at this time.
0 commit comments