mirror of
https://github.com/actions/setup-python.git
synced 2026-01-20 12:48:54 +08:00
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:
parent
0ebf233433
commit
e621a16884
4 changed files with 66 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue