mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 15:32:13 +00: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
14
.github/workflows/test-pypy.yml
vendored
14
.github/workflows/test-pypy.yml
vendored
|
@ -44,3 +44,17 @@ jobs:
|
||||||
|
|
||||||
- name: Run simple code
|
- name: Run simple code
|
||||||
run: python -c 'import math; print(math.factorial(5))'
|
run: python -c 'import math; print(math.factorial(5))'
|
||||||
|
|
||||||
|
- name: Assert PyPy is running
|
||||||
|
run: |
|
||||||
|
import platform
|
||||||
|
assert platform.python_implementation().lower() == "pypy"
|
||||||
|
shell: python
|
||||||
|
|
||||||
|
- name: Assert expected binaries (or symlinks) are present
|
||||||
|
run: |
|
||||||
|
EXECUTABLE=${{ matrix.pypy }}
|
||||||
|
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
|
||||||
|
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
|
||||||
|
${EXECUTABLE} --version
|
||||||
|
shell: bash
|
||||||
|
|
18
dist/setup/index.js
vendored
18
dist/setup/index.js
vendored
|
@ -2064,6 +2064,19 @@ const utils_1 = __webpack_require__(163);
|
||||||
const semver = __importStar(__webpack_require__(876));
|
const semver = __importStar(__webpack_require__(876));
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const tc = __importStar(__webpack_require__(533));
|
const tc = __importStar(__webpack_require__(533));
|
||||||
|
// TODO remove the following function once v7.3.9 is in tool cache
|
||||||
|
function createPyPySymlink(pypyBinaryPath, pythonVersion) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
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 = utils_1.IS_WINDOWS ? '.exe' : '';
|
||||||
|
core.info('Creating symlinks...');
|
||||||
|
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `pypy${pypyMajorMinorBinaryPostfix}${binaryExtension}`, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
function findPyPyVersion(versionSpec, architecture) {
|
function findPyPyVersion(versionSpec, architecture) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let resolvedPyPyVersion = '';
|
let resolvedPyPyVersion = '';
|
||||||
|
@ -2081,6 +2094,8 @@ function findPyPyVersion(versionSpec, architecture) {
|
||||||
const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin';
|
const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin';
|
||||||
const _binDir = path.join(installDir, pipDir);
|
const _binDir = path.join(installDir, pipDir);
|
||||||
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
||||||
|
// TODO remove the following line once v7.3.9 is in tool cache
|
||||||
|
yield createPyPySymlink(pythonLocation, resolvedPythonVersion);
|
||||||
core.exportVariable('pythonLocation', pythonLocation);
|
core.exportVariable('pythonLocation', pythonLocation);
|
||||||
core.addPath(pythonLocation);
|
core.addPath(pythonLocation);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
|
@ -10605,11 +10620,14 @@ function createPyPySymlink(pypyBinaryPath, pythonVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const version = semver.coerce(pythonVersion);
|
const version = semver.coerce(pythonVersion);
|
||||||
const pythonBinaryPostfix = semver.major(version);
|
const pythonBinaryPostfix = semver.major(version);
|
||||||
|
const pythonMinor = semver.minor(version);
|
||||||
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
|
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
|
||||||
|
const pypyMajorMinorBinaryPostfix = `${pythonBinaryPostfix}.${pythonMinor}`;
|
||||||
let binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
|
let binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
|
||||||
core.info('Creating symlinks...');
|
core.info('Creating symlinks...');
|
||||||
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `python${pythonBinaryPostfix}${binaryExtension}`, true);
|
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `python${pythonBinaryPostfix}${binaryExtension}`, true);
|
||||||
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `python${binaryExtension}`, true);
|
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `python${binaryExtension}`, true);
|
||||||
|
utils_1.createSymlinkInFolder(pypyBinaryPath, `pypy${pypyBinaryPostfix}${binaryExtension}`, `pypy${pypyMajorMinorBinaryPostfix}${binaryExtension}`, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function installPip(pythonLocation) {
|
function installPip(pythonLocation) {
|
||||||
|
|
|
@ -6,7 +6,8 @@ import {
|
||||||
validateVersion,
|
validateVersion,
|
||||||
getPyPyVersionFromPath,
|
getPyPyVersionFromPath,
|
||||||
readExactPyPyVersionFile,
|
readExactPyPyVersionFile,
|
||||||
validatePythonVersionFormatForPyPy
|
validatePythonVersionFormatForPyPy,
|
||||||
|
createSymlinkInFolder
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
@ -18,6 +19,27 @@ interface IPyPyVersionSpec {
|
||||||
pythonVersion: string;
|
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(
|
export async function findPyPyVersion(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
architecture: string
|
architecture: string
|
||||||
|
@ -49,6 +71,8 @@ export async function findPyPyVersion(
|
||||||
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
|
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
|
||||||
const _binDir = path.join(installDir, pipDir);
|
const _binDir = path.join(installDir, pipDir);
|
||||||
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
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.exportVariable('pythonLocation', pythonLocation);
|
||||||
core.addPath(pythonLocation);
|
core.addPath(pythonLocation);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
|
|
|
@ -98,7 +98,9 @@ async function createPyPySymlink(
|
||||||
) {
|
) {
|
||||||
const version = semver.coerce(pythonVersion)!;
|
const version = semver.coerce(pythonVersion)!;
|
||||||
const pythonBinaryPostfix = semver.major(version);
|
const pythonBinaryPostfix = semver.major(version);
|
||||||
|
const pythonMinor = semver.minor(version);
|
||||||
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
|
const pypyBinaryPostfix = pythonBinaryPostfix === 2 ? '' : '3';
|
||||||
|
const pypyMajorMinorBinaryPostfix = `${pythonBinaryPostfix}.${pythonMinor}`;
|
||||||
let binaryExtension = IS_WINDOWS ? '.exe' : '';
|
let binaryExtension = IS_WINDOWS ? '.exe' : '';
|
||||||
|
|
||||||
core.info('Creating symlinks...');
|
core.info('Creating symlinks...');
|
||||||
|
@ -115,6 +117,13 @@ async function createPyPySymlink(
|
||||||
`python${binaryExtension}`,
|
`python${binaryExtension}`,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
createSymlinkInFolder(
|
||||||
|
pypyBinaryPath,
|
||||||
|
`pypy${pypyBinaryPostfix}${binaryExtension}`,
|
||||||
|
`pypy${pypyMajorMinorBinaryPostfix}${binaryExtension}`,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function installPip(pythonLocation: string) {
|
async function installPip(pythonLocation: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue