Skip to content

Commit 8039c45

Browse files
authored
fix: install PyPy on Linux ARM64 (#1011)
* ci: check non-eol versions of PyPy are available on all runners * fix: install PyPy on Linux ARM64 * ci: remove eol ubuntu-20.04
1 parent 4237552 commit 8039c45

File tree

3 files changed

+73
-10
lines changed

3 files changed

+73
-10
lines changed

.github/workflows/test-pypy.yml

+53
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,59 @@ jobs:
6969
${EXECUTABLE} --version
7070
shell: bash
7171

72+
check-non-eol:
73+
name: Check non-eol ${{ matrix.pypy }} on ${{ matrix.os }}
74+
runs-on: ${{ matrix.os }}
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
os:
79+
- macos-13
80+
- macos-14
81+
- macos-15
82+
- windows-2019
83+
- windows-2022
84+
- windows-2025
85+
- ubuntu-22.04
86+
- ubuntu-24.04
87+
- ubuntu-22.04-arm
88+
- ubuntu-24.04-arm
89+
pypy: ['pypy-2.7', 'pypy-3.10']
90+
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v4
94+
95+
- name: setup-python ${{ matrix.pypy }}
96+
id: setup-python
97+
uses: ./
98+
with:
99+
python-version: ${{ matrix.pypy }}
100+
101+
- name: Check python-path
102+
run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}'
103+
shell: bash
104+
105+
- name: PyPy and Python version
106+
run: python --version
107+
108+
- name: Run simple code
109+
run: python -c 'import math; print(math.factorial(5))'
110+
111+
- name: Assert PyPy is running
112+
run: |
113+
import platform
114+
assert platform.python_implementation().lower() == "pypy"
115+
shell: python
116+
117+
- name: Assert expected binaries (or symlinks) are present
118+
run: |
119+
EXECUTABLE=${{ matrix.pypy }}
120+
EXECUTABLE=${EXECUTABLE/pypy-/pypy} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
121+
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
122+
${EXECUTABLE} --version
123+
shell: bash
124+
72125
setup-pypy-noenv:
73126
name: Setup PyPy ${{ matrix.pypy }} ${{ matrix.os }} (noenv)
74127
runs-on: ${{ matrix.os }}

dist/setup/index.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -100062,28 +100062,33 @@ function pypyVersionToSemantic(versionSpec) {
100062100062
}
100063100063
exports.pypyVersionToSemantic = pypyVersionToSemantic;
100064100064
function isArchPresentForWindows(item, architecture) {
100065-
architecture = replaceX32toX86(architecture);
100065+
architecture = pypyArchitecture(architecture);
100066100066
return item.files.some((file) => utils_1.WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture);
100067100067
}
100068100068
exports.isArchPresentForWindows = isArchPresentForWindows;
100069100069
function isArchPresentForMacOrLinux(item, architecture, platform) {
100070+
architecture = pypyArchitecture(architecture);
100070100071
return item.files.some((file) => file.arch === architecture && file.platform === platform);
100071100072
}
100072100073
exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux;
100073100074
function findAssetForWindows(releases, architecture) {
100074-
architecture = replaceX32toX86(architecture);
100075+
architecture = pypyArchitecture(architecture);
100075100076
return releases.files.find((item) => utils_1.WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture);
100076100077
}
100077100078
exports.findAssetForWindows = findAssetForWindows;
100078100079
function findAssetForMacOrLinux(releases, architecture, platform) {
100080+
architecture = pypyArchitecture(architecture);
100079100081
return releases.files.find((item) => item.arch === architecture && item.platform === platform);
100080100082
}
100081100083
exports.findAssetForMacOrLinux = findAssetForMacOrLinux;
100082-
function replaceX32toX86(architecture) {
100083-
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
100084-
if (architecture === 'x32') {
100084+
function pypyArchitecture(architecture) {
100085+
if (utils_1.IS_WINDOWS && architecture === 'x32') {
100086+
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
100085100087
architecture = 'x86';
100086100088
}
100089+
else if (utils_1.IS_LINUX && architecture === 'arm64') {
100090+
architecture = 'aarch64';
100091+
}
100087100092
return architecture;
100088100093
}
100089100094

src/install-pypy.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as exec from '@actions/exec';
88
import fs from 'fs';
99

1010
import {
11+
IS_LINUX,
1112
IS_WINDOWS,
1213
WINDOWS_PLATFORMS,
1314
IPyPyManifestRelease,
@@ -246,7 +247,7 @@ export function pypyVersionToSemantic(versionSpec: string) {
246247
}
247248

248249
export function isArchPresentForWindows(item: any, architecture: string) {
249-
architecture = replaceX32toX86(architecture);
250+
architecture = pypyArchitecture(architecture);
250251
return item.files.some(
251252
(file: any) =>
252253
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture
@@ -258,13 +259,14 @@ export function isArchPresentForMacOrLinux(
258259
architecture: string,
259260
platform: string
260261
) {
262+
architecture = pypyArchitecture(architecture);
261263
return item.files.some(
262264
(file: any) => file.arch === architecture && file.platform === platform
263265
);
264266
}
265267

266268
export function findAssetForWindows(releases: any, architecture: string) {
267-
architecture = replaceX32toX86(architecture);
269+
architecture = pypyArchitecture(architecture);
268270
return releases.files.find(
269271
(item: any) =>
270272
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture
@@ -276,15 +278,18 @@ export function findAssetForMacOrLinux(
276278
architecture: string,
277279
platform: string
278280
) {
281+
architecture = pypyArchitecture(architecture);
279282
return releases.files.find(
280283
(item: any) => item.arch === architecture && item.platform === platform
281284
);
282285
}
283286

284-
function replaceX32toX86(architecture: string): string {
285-
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
286-
if (architecture === 'x32') {
287+
function pypyArchitecture(architecture: string): string {
288+
if (IS_WINDOWS && architecture === 'x32') {
289+
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
287290
architecture = 'x86';
291+
} else if (IS_LINUX && architecture === 'arm64') {
292+
architecture = 'aarch64';
288293
}
289294
return architecture;
290295
}

0 commit comments

Comments
 (0)