Create missing pypyX.Y symlinks

`pypyX.Y.exe` executables are missing from PyPy archives on Windows before v7.3.9 (X.Y < 3.9)
`pypy2.7` symlinks are also missing from macOS/Linux PyPy archives before v7.3.9

relates to #346
This commit is contained in:
mayeut 2022-03-05 13:06:37 +01:00
parent 0ebf233433
commit e621a16884
No known key found for this signature in database
GPG key ID: 8B03CED67D3ABFBA
4 changed files with 66 additions and 1 deletions

View file

@ -6,7 +6,8 @@ import {
validateVersion,
getPyPyVersionFromPath,
readExactPyPyVersionFile,
validatePythonVersionFormatForPyPy
validatePythonVersionFormatForPyPy,
createSymlinkInFolder
} from './utils';
import * as semver from 'semver';
@ -18,6 +19,27 @@ interface IPyPyVersionSpec {
pythonVersion: string;
}
// TODO remove the following function once v7.3.9 is in tool cache
async function createPyPySymlink(
pypyBinaryPath: string,
pythonVersion: string
) {
const version = semver.coerce(pythonVersion)!;
const pythonBinaryPostfix = semver.major(version);
const pythonMinor = semver.minor(version);
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
const pypyMajorMinorBinaryPostfix = `${pythonBinaryPostfix}.${pythonMinor}`;
let binaryExtension = IS_WINDOWS ? '.exe' : '';
core.info('Creating symlinks...');
createSymlinkInFolder(
pypyBinaryPath,
`pypy${pypyBinaryPostfix}${binaryExtension}`,
`pypy${pypyMajorMinorBinaryPostfix}${binaryExtension}`,
true
);
}
export async function findPyPyVersion(
versionSpec: string,
architecture: string
@ -49,6 +71,8 @@ export async function findPyPyVersion(
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
const _binDir = path.join(installDir, pipDir);
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
// TODO remove the following line once v7.3.9 is in tool cache
await createPyPySymlink(pythonLocation, resolvedPythonVersion);
core.exportVariable('pythonLocation', pythonLocation);
core.addPath(pythonLocation);
core.addPath(_binDir);