mirror of
https://github.com/actions/setup-python.git
synced 2024-12-27 09:55:23 +01:00
Add architecture input check for PyPy for Windows platform (#520)
* Revert cache index.js * build cache index file * Refactor * Debug * Debug * Debug * Debug * Debug * Debug * Debug * Debug * Format code * Rebuild dist * Minor refactor * Format code * Minor fixes * Check platform firstly
This commit is contained in:
parent
13ae5bb136
commit
8bcd2560e2
2 changed files with 31 additions and 17 deletions
23
dist/setup/index.js
vendored
23
dist/setup/index.js
vendored
|
@ -66577,7 +66577,7 @@ function findRelease(releases, pythonVersion, pypyVersion, architecture) {
|
||||||
semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion);
|
semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion);
|
||||||
const isArchPresent = item.files &&
|
const isArchPresent = item.files &&
|
||||||
(utils_1.IS_WINDOWS
|
(utils_1.IS_WINDOWS
|
||||||
? isArchPresentForWindows(item)
|
? isArchPresentForWindows(item, architecture)
|
||||||
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
||||||
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
||||||
});
|
});
|
||||||
|
@ -66590,7 +66590,7 @@ function findRelease(releases, pythonVersion, pypyVersion, architecture) {
|
||||||
});
|
});
|
||||||
const foundRelease = sortedReleases[0];
|
const foundRelease = sortedReleases[0];
|
||||||
const foundAsset = utils_1.IS_WINDOWS
|
const foundAsset = utils_1.IS_WINDOWS
|
||||||
? findAssetForWindows(foundRelease)
|
? findAssetForWindows(foundRelease, architecture)
|
||||||
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
||||||
return {
|
return {
|
||||||
foundAsset,
|
foundAsset,
|
||||||
|
@ -66613,24 +66613,31 @@ function pypyVersionToSemantic(versionSpec) {
|
||||||
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
||||||
}
|
}
|
||||||
exports.pypyVersionToSemantic = pypyVersionToSemantic;
|
exports.pypyVersionToSemantic = pypyVersionToSemantic;
|
||||||
function isArchPresentForWindows(item) {
|
function isArchPresentForWindows(item, architecture) {
|
||||||
return item.files.some((file) => utils_1.WINDOWS_ARCHS.includes(file.arch) &&
|
architecture = replaceX32toX86(architecture);
|
||||||
utils_1.WINDOWS_PLATFORMS.includes(file.platform));
|
return item.files.some((file) => utils_1.WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture);
|
||||||
}
|
}
|
||||||
exports.isArchPresentForWindows = isArchPresentForWindows;
|
exports.isArchPresentForWindows = isArchPresentForWindows;
|
||||||
function isArchPresentForMacOrLinux(item, architecture, platform) {
|
function isArchPresentForMacOrLinux(item, architecture, platform) {
|
||||||
return item.files.some((file) => file.arch === architecture && file.platform === platform);
|
return item.files.some((file) => file.arch === architecture && file.platform === platform);
|
||||||
}
|
}
|
||||||
exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux;
|
exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux;
|
||||||
function findAssetForWindows(releases) {
|
function findAssetForWindows(releases, architecture) {
|
||||||
return releases.files.find((item) => utils_1.WINDOWS_ARCHS.includes(item.arch) &&
|
architecture = replaceX32toX86(architecture);
|
||||||
utils_1.WINDOWS_PLATFORMS.includes(item.platform));
|
return releases.files.find((item) => utils_1.WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture);
|
||||||
}
|
}
|
||||||
exports.findAssetForWindows = findAssetForWindows;
|
exports.findAssetForWindows = findAssetForWindows;
|
||||||
function findAssetForMacOrLinux(releases, architecture, platform) {
|
function findAssetForMacOrLinux(releases, architecture, platform) {
|
||||||
return releases.files.find((item) => item.arch === architecture && item.platform === platform);
|
return releases.files.find((item) => item.arch === architecture && item.platform === platform);
|
||||||
}
|
}
|
||||||
exports.findAssetForMacOrLinux = findAssetForMacOrLinux;
|
exports.findAssetForMacOrLinux = findAssetForMacOrLinux;
|
||||||
|
function replaceX32toX86(architecture) {
|
||||||
|
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
|
||||||
|
if (architecture === 'x32') {
|
||||||
|
architecture = 'x86';
|
||||||
|
}
|
||||||
|
return architecture;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -8,7 +8,6 @@ import fs from 'fs';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IS_WINDOWS,
|
IS_WINDOWS,
|
||||||
WINDOWS_ARCHS,
|
|
||||||
WINDOWS_PLATFORMS,
|
WINDOWS_PLATFORMS,
|
||||||
IPyPyManifestRelease,
|
IPyPyManifestRelease,
|
||||||
createSymlinkInFolder,
|
createSymlinkInFolder,
|
||||||
|
@ -157,7 +156,7 @@ export function findRelease(
|
||||||
const isArchPresent =
|
const isArchPresent =
|
||||||
item.files &&
|
item.files &&
|
||||||
(IS_WINDOWS
|
(IS_WINDOWS
|
||||||
? isArchPresentForWindows(item)
|
? isArchPresentForWindows(item, architecture)
|
||||||
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
||||||
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
||||||
});
|
});
|
||||||
|
@ -181,7 +180,7 @@ export function findRelease(
|
||||||
|
|
||||||
const foundRelease = sortedReleases[0];
|
const foundRelease = sortedReleases[0];
|
||||||
const foundAsset = IS_WINDOWS
|
const foundAsset = IS_WINDOWS
|
||||||
? findAssetForWindows(foundRelease)
|
? findAssetForWindows(foundRelease, architecture)
|
||||||
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -205,11 +204,11 @@ export function pypyVersionToSemantic(versionSpec: string) {
|
||||||
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArchPresentForWindows(item: any) {
|
export function isArchPresentForWindows(item: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return item.files.some(
|
return item.files.some(
|
||||||
(file: any) =>
|
(file: any) =>
|
||||||
WINDOWS_ARCHS.includes(file.arch) &&
|
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(file.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +222,11 @@ export function isArchPresentForMacOrLinux(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findAssetForWindows(releases: any) {
|
export function findAssetForWindows(releases: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return releases.files.find(
|
return releases.files.find(
|
||||||
(item: any) =>
|
(item: any) =>
|
||||||
WINDOWS_ARCHS.includes(item.arch) &&
|
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(item.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,3 +239,11 @@ export function findAssetForMacOrLinux(
|
||||||
(item: any) => item.arch === architecture && item.platform === platform
|
(item: any) => item.arch === architecture && item.platform === platform
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceX32toX86(architecture: string): string {
|
||||||
|
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
|
||||||
|
if (architecture === 'x32') {
|
||||||
|
architecture = 'x86';
|
||||||
|
}
|
||||||
|
return architecture;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue