Skip to content

Commit

Permalink
Create missing pypyX.Y symlinks
Browse files Browse the repository at this point in the history
`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 actions#346
  • Loading branch information
mayeut committed Apr 2, 2022
1 parent 156f48c commit 06cfef0
Show file tree
Hide file tree
Showing 2 changed files with 1,800 additions and 1,877 deletions.
3,651 changes: 1,775 additions & 1,876 deletions dist/setup/index.js

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion src/find-pypy.ts
Expand Up @@ -6,7 +6,8 @@ import {
validateVersion,
getPyPyVersionFromPath,
readExactPyPyVersionFile,
validatePythonVersionFormatForPyPy
validatePythonVersionFormatForPyPy,
createSymlinkInFolder
} from './utils';

import * as semver from 'semver';
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 06cfef0

Please sign in to comment.