1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-09 04:42:20 +02:00

Fix PyPy installation on Windows to adopt new parameters format (#201)

* test for pypy new version notation

* formatting

* uncommented condition

* test

* added pypy to test matrix

* test

* test

* restored all tests

* removed logs, added multiarch support for toolcache

* reduced test matrix

* removed extra condition about arch
This commit is contained in:
Alena Sviridenko 2021-04-12 20:59:38 +03:00 committed by GitHub
parent a1121449a2
commit dc73133d4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 137 additions and 21 deletions

View file

@ -2,6 +2,7 @@ import * as path from 'path';
import * as pypyInstall from './install-pypy';
import {
IS_WINDOWS,
WINDOWS_ARCHS,
validateVersion,
getPyPyVersionFromPath,
readExactPyPyVersionFile,
@ -27,11 +28,6 @@ export async function findPyPyVersion(
const pypyVersionSpec = parsePyPyVersion(versionSpec);
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
if (IS_WINDOWS && architecture === 'x64') {
architecture = 'x86';
}
({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache(
pypyVersionSpec.pythonVersion,
pypyVersionSpec.pypyVersion,
@ -67,7 +63,9 @@ export function findPyPyToolCache(
) {
let resolvedPyPyVersion = '';
let resolvedPythonVersion = '';
let installDir: string | null = tc.find('PyPy', pythonVersion, architecture);
let installDir: string | null = IS_WINDOWS
? findPyPyInstallDirForWindows(pythonVersion)
: tc.find('PyPy', pythonVersion, architecture);
if (installDir) {
// 'tc.find' finds tool based on Python version but we also need to check
@ -129,3 +127,14 @@ export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
pythonVersion: pythonVersion
};
}
export function findPyPyInstallDirForWindows(pythonVersion: string): string {
let installDir = '';
WINDOWS_ARCHS.forEach(
architecture =>
(installDir = installDir || tc.find('PyPy', pythonVersion, architecture))
);
return installDir;
}