Skip to content

Commit 3b3f2de

Browse files
update pypy3 to point to 3.6 (#164)
1 parent 723e46d commit 3b3f2de

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

.github/workflows/test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,24 @@ jobs:
9090

9191
- name: Run simple code
9292
run: python -c 'import math; print(math.factorial(5))'
93+
94+
setup-pypy:
95+
name: Setup PyPy ${{ matrix.os }}
96+
runs-on: ${{ matrix.os }}
97+
strategy:
98+
fail-fast: false
99+
matrix:
100+
os: [macos-latest, windows-latest, ubuntu-16.04, ubuntu-18.04]
101+
steps:
102+
- name: Checkout
103+
uses: actions/checkout@v2
104+
105+
- name: setup-python pypy3
106+
uses: ./
107+
with:
108+
python-version: 'pypy3'
109+
110+
- name: setup-python pypy2
111+
uses: ./
112+
with:
113+
python-version: 'pypy2'

dist/index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -6445,7 +6445,7 @@ function installPython(workingDirectory) {
64456445
return __awaiter(this, void 0, void 0, function* () {
64466446
const options = {
64476447
cwd: workingDirectory,
6448-
env: Object.assign(Object.assign({}, process.env), IS_LINUX && { 'LD_LIBRARY_PATH': path.join(workingDirectory, 'lib') }),
6448+
env: Object.assign(Object.assign({}, process.env), (IS_LINUX && { LD_LIBRARY_PATH: path.join(workingDirectory, 'lib') })),
64496449
silent: true,
64506450
listeners: {
64516451
stdout: (data) => {
@@ -6718,7 +6718,7 @@ function binDir(installDir) {
67186718
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
67196719
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
67206720
function usePyPy(majorVersion, architecture) {
6721-
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
6721+
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
67226722
let installDir = findPyPy(architecture);
67236723
if (!installDir && IS_WINDOWS) {
67246724
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
@@ -6765,7 +6765,9 @@ function useCpythonVersion(version, architecture) {
67656765
}
67666766
core.exportVariable('pythonLocation', installDir);
67676767
if (IS_LINUX) {
6768-
const libPath = (process.env.LD_LIBRARY_PATH) ? `:${process.env.LD_LIBRARY_PATH}` : '';
6768+
const libPath = process.env.LD_LIBRARY_PATH
6769+
? `:${process.env.LD_LIBRARY_PATH}`
6770+
: '';
67696771
const pyLibPath = path.join(installDir, 'lib');
67706772
if (!libPath.split(':').includes(pyLibPath)) {
67716773
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
@@ -6819,9 +6821,10 @@ function findPythonVersion(version, architecture) {
68196821
return __awaiter(this, void 0, void 0, function* () {
68206822
switch (version.toUpperCase()) {
68216823
case 'PYPY2':
6822-
return usePyPy(2, architecture);
6824+
return usePyPy('2', architecture);
68236825
case 'PYPY3':
6824-
return usePyPy(3, architecture);
6826+
// keep pypy3 pointing to 3.6 for backward compatibility
6827+
return usePyPy('3.6', architecture);
68256828
default:
68266829
return yield useCpythonVersion(version, architecture);
68276830
}

src/find-python.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ function binDir(installDir: string): string {
3737
// A particular version of PyPy may contain one or more versions of the Python interpreter.
3838
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
3939
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
40-
function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion {
41-
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
40+
function usePyPy(
41+
majorVersion: '2' | '3.6',
42+
architecture: string
43+
): InstalledVersion {
44+
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
4245
let installDir: string | null = findPyPy(architecture);
4346

4447
if (!installDir && IS_WINDOWS) {
@@ -188,9 +191,10 @@ export async function findPythonVersion(
188191
): Promise<InstalledVersion> {
189192
switch (version.toUpperCase()) {
190193
case 'PYPY2':
191-
return usePyPy(2, architecture);
194+
return usePyPy('2', architecture);
192195
case 'PYPY3':
193-
return usePyPy(3, architecture);
196+
// keep pypy3 pointing to 3.6 for backward compatibility
197+
return usePyPy('3.6', architecture);
194198
default:
195199
return await useCpythonVersion(version, architecture);
196200
}

0 commit comments

Comments
 (0)