1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-09 04:42:20 +02:00

graalpy: add graalpy early-access and windows builds

This commit is contained in:
Tim Felgentreff 2024-05-28 14:44:41 +02:00
parent 82c7e631bb
commit fc9bcb4a04
8 changed files with 880 additions and 926 deletions

View file

@ -15,7 +15,6 @@ import {
IGraalPyManifestRelease,
createSymlinkInFolder,
isNightlyKeyword,
getBinaryDirectory,
getNextPageUrl
} from './utils';
@ -64,7 +63,11 @@ export async function installGraalPy(
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
core.info('Extracting downloaded archive...');
downloadDir = await tc.extractTar(graalpyPath);
if (IS_WINDOWS) {
downloadDir = await tc.extractZip(graalpyPath);
} else {
downloadDir = await tc.extractTar(graalpyPath);
}
// root folder in archive can have unpredictable name so just take the first folder
// downloadDir is unique folder under TEMP and can't contain any other folders
@ -81,7 +84,7 @@ export async function installGraalPy(
);
}
const binaryPath = getBinaryDirectory(installDir);
const binaryPath = path.join(installDir, 'bin');
await createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
await installPip(binaryPath);
@ -115,6 +118,9 @@ export async function getAvailableGraalPyVersions() {
headers.authorization = AUTH;
}
/*
Get releases first.
*/
let url: string | null =
'https://api.github.com/repos/oracle/graalpython/releases';
const result: IGraalPyManifestRelease[] = [];
@ -130,6 +136,23 @@ export async function getAvailableGraalPyVersions() {
url = getNextPageUrl(response);
} while (url);
/*
Add pre-release builds.
*/
url =
'https://api.github.com/repos/graalvm/graal-languages-ea-builds/releases';
do {
const response: ifm.TypedResponse<IGraalPyManifestRelease[]> =
await http.getJson(url, headers);
if (!response.result) {
throw new Error(
`Unable to retrieve the list of available GraalPy versions from '${url}'`
);
}
result.push(...response.result);
url = getNextPageUrl(response);
} while (url);
return result;
}
@ -175,7 +198,8 @@ async function installPip(pythonLocation: string) {
}
export function graalPyTagToVersion(tag: string) {
const versionPattern = /.*-(\d+\.\d+\.\d+(?:\.\d+)?)((?:a|b|rc))?(\d*)?/;
const versionPattern =
/.*-(\d+\.\d+\.\d+(?:\.\d+)?)(?:-((?:ea|a|b|rc))\.0*(\d*))?/;
const match = tag.match(versionPattern);
if (match && match[2]) {
return `${match[1]}-${match[2]}.${match[3]}`;
@ -251,10 +275,11 @@ export function findAsset(
) {
const graalpyArch = toGraalPyArchitecture(architecture);
const graalpyPlatform = toGraalPyPlatform(platform);
const graalpyExt = platform == 'win32' ? 'zip' : 'tar.gz';
const found = item.assets.filter(
file =>
file.name.startsWith('graalpy') &&
file.name.endsWith(`-${graalpyPlatform}-${graalpyArch}.tar.gz`)
file.name.endsWith(`-${graalpyPlatform}-${graalpyArch}.${graalpyExt}`)
);
/*
In the future there could be more variants of GraalPy for a single release. Pick the shortest name, that one is the most likely to be the primary variant.