fix: install PyPy on Linux ARM64

This commit is contained in:
mayeut 2025-01-19 11:58:33 +01:00
parent db8d0cb5aa
commit 28bb880b4f
No known key found for this signature in database
GPG key ID: 8B03CED67D3ABFBA
2 changed files with 20 additions and 10 deletions

15
dist/setup/index.js vendored
View file

@ -91554,28 +91554,33 @@ function pypyVersionToSemantic(versionSpec) {
} }
exports.pypyVersionToSemantic = pypyVersionToSemantic; exports.pypyVersionToSemantic = pypyVersionToSemantic;
function isArchPresentForWindows(item, architecture) { function isArchPresentForWindows(item, architecture) {
architecture = replaceX32toX86(architecture); architecture = pypyArchitecture(architecture);
return item.files.some((file) => utils_1.WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture); return item.files.some((file) => utils_1.WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture);
} }
exports.isArchPresentForWindows = isArchPresentForWindows; exports.isArchPresentForWindows = isArchPresentForWindows;
function isArchPresentForMacOrLinux(item, architecture, platform) { function isArchPresentForMacOrLinux(item, architecture, platform) {
architecture = pypyArchitecture(architecture);
return item.files.some((file) => file.arch === architecture && file.platform === platform); return item.files.some((file) => file.arch === architecture && file.platform === platform);
} }
exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux;
function findAssetForWindows(releases, architecture) { function findAssetForWindows(releases, architecture) {
architecture = replaceX32toX86(architecture); architecture = pypyArchitecture(architecture);
return releases.files.find((item) => utils_1.WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture); return releases.files.find((item) => utils_1.WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture);
} }
exports.findAssetForWindows = findAssetForWindows; exports.findAssetForWindows = findAssetForWindows;
function findAssetForMacOrLinux(releases, architecture, platform) { function findAssetForMacOrLinux(releases, architecture, platform) {
architecture = pypyArchitecture(architecture);
return releases.files.find((item) => item.arch === architecture && item.platform === platform); return releases.files.find((item) => item.arch === architecture && item.platform === platform);
} }
exports.findAssetForMacOrLinux = findAssetForMacOrLinux; exports.findAssetForMacOrLinux = findAssetForMacOrLinux;
function replaceX32toX86(architecture) { function pypyArchitecture(architecture) {
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (utils_1.IS_WINDOWS && architecture === 'x32') {
if (architecture === 'x32') { // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
architecture = 'x86'; architecture = 'x86';
} }
else if (utils_1.IS_LINUX && architecture === 'arm64') {
architecture = 'aarch64';
}
return architecture; return architecture;
} }

View file

@ -8,6 +8,7 @@ import * as exec from '@actions/exec';
import fs from 'fs'; import fs from 'fs';
import { import {
IS_LINUX,
IS_WINDOWS, IS_WINDOWS,
WINDOWS_PLATFORMS, WINDOWS_PLATFORMS,
IPyPyManifestRelease, IPyPyManifestRelease,
@ -246,7 +247,7 @@ export function pypyVersionToSemantic(versionSpec: string) {
} }
export function isArchPresentForWindows(item: any, architecture: string) { export function isArchPresentForWindows(item: any, architecture: string) {
architecture = replaceX32toX86(architecture); architecture = pypyArchitecture(architecture);
return item.files.some( return item.files.some(
(file: any) => (file: any) =>
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture
@ -258,13 +259,14 @@ export function isArchPresentForMacOrLinux(
architecture: string, architecture: string,
platform: string platform: string
) { ) {
architecture = pypyArchitecture(architecture);
return item.files.some( return item.files.some(
(file: any) => file.arch === architecture && file.platform === platform (file: any) => file.arch === architecture && file.platform === platform
); );
} }
export function findAssetForWindows(releases: any, architecture: string) { export function findAssetForWindows(releases: any, architecture: string) {
architecture = replaceX32toX86(architecture); architecture = pypyArchitecture(architecture);
return releases.files.find( return releases.files.find(
(item: any) => (item: any) =>
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture
@ -276,15 +278,18 @@ export function findAssetForMacOrLinux(
architecture: string, architecture: string,
platform: string platform: string
) { ) {
architecture = pypyArchitecture(architecture);
return releases.files.find( return releases.files.find(
(item: any) => item.arch === architecture && item.platform === platform (item: any) => item.arch === architecture && item.platform === platform
); );
} }
function replaceX32toX86(architecture: string): string { function pypyArchitecture(architecture: string): string {
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (IS_WINDOWS && architecture === 'x32') {
if (architecture === 'x32') { // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
architecture = 'x86'; architecture = 'x86';
} else if (IS_LINUX && architecture === 'arm64') {
architecture = 'aarch64';
} }
return architecture; return architecture;
} }