mirror of
https://github.com/actions/setup-python.git
synced 2025-04-21 17:23:52 +00:00
format, lint and build
This commit is contained in:
parent
f40a022aaf
commit
6db14b26fd
@ -10,13 +10,11 @@ import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import * as finder from '../src/find-graalpy';
|
||||
import {
|
||||
IGraalPyManifestRelease,
|
||||
} from '../src/utils';
|
||||
import {IGraalPyManifestRelease} from '../src/utils';
|
||||
|
||||
import manifestData from './data/graalpy.json';
|
||||
|
||||
let architecture = 'x64';
|
||||
const architecture = 'x64';
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
@ -25,7 +23,7 @@ describe('parseGraalPyVersion', () => {
|
||||
it.each([
|
||||
['graalpy-23', '23'],
|
||||
['graalpy-23.0', '23.0'],
|
||||
['graalpy23.0', '23.0'],
|
||||
['graalpy23.0', '23.0']
|
||||
])('%s -> %s', (input, expected) => {
|
||||
expect(finder.parseGraalPyVersion(input)).toEqual(expected);
|
||||
});
|
||||
@ -308,9 +306,7 @@ describe('findGraalPyVersion', () => {
|
||||
)
|
||||
).resolves.toEqual('23.0.0');
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
'Resolved as GraalPy 23.0.0'
|
||||
);
|
||||
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
|
||||
});
|
||||
|
||||
it('check-latest enabled version found and install successfully', async () => {
|
||||
@ -329,9 +325,7 @@ describe('findGraalPyVersion', () => {
|
||||
false
|
||||
)
|
||||
).resolves.toEqual('23.0.0');
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
'Resolved as GraalPy 23.0.0'
|
||||
);
|
||||
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
|
||||
});
|
||||
|
||||
it('check-latest enabled version is not found and used from toolcache', async () => {
|
||||
@ -366,7 +360,13 @@ describe('findGraalPyVersion', () => {
|
||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, false)
|
||||
finder.findGraalPyVersion(
|
||||
'graalpy23.1',
|
||||
architecture,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
)
|
||||
).rejects.toThrow();
|
||||
await expect(
|
||||
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true)
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
|
||||
import manifestData from './data/graalpy.json';
|
||||
|
||||
let architecture: string = 'x64';
|
||||
const architecture = 'x64';
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
@ -36,7 +36,7 @@ describe('findRelease', () => {
|
||||
const result = JSON.stringify(manifestData);
|
||||
const releases = JSON.parse(result) as IGraalPyManifestRelease[];
|
||||
const extension = 'tar.gz';
|
||||
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
|
||||
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
|
||||
const extensionName = IS_WINDOWS
|
||||
? `windows-${arch}.${extension}`
|
||||
: `${process.platform}-${arch}.${extension}`;
|
||||
@ -67,24 +67,14 @@ describe('findRelease', () => {
|
||||
it("GraalPy version doesn't match", () => {
|
||||
const graalpyVersion = '12.0.0';
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, false)
|
||||
).toEqual(null);
|
||||
});
|
||||
|
||||
it('GraalPy version matches', () => {
|
||||
const graalpyVersion = '23.0.0';
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, false)
|
||||
).toMatchObject({
|
||||
foundAsset: files,
|
||||
resolvedGraalPyVersion: graalpyVersion
|
||||
@ -94,12 +84,7 @@ describe('findRelease', () => {
|
||||
it('Preview version of GraalPy is found', () => {
|
||||
const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1');
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, false)
|
||||
).toMatchObject({
|
||||
foundAsset: {
|
||||
name: `graalpython-23.1.0a1-${extensionName}`,
|
||||
@ -112,12 +97,7 @@ describe('findRelease', () => {
|
||||
it('Latest GraalPy is found', () => {
|
||||
const graalpyVersion = 'x';
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, false)
|
||||
).toMatchObject({
|
||||
foundAsset: files,
|
||||
resolvedGraalPyVersion: '23.0.0'
|
||||
@ -127,20 +107,10 @@ describe('findRelease', () => {
|
||||
it('GraalPy version matches semver (pre-release)', () => {
|
||||
const graalpyVersion = '23.1.x';
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, false)
|
||||
).toBeNull();
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
true
|
||||
)
|
||||
installer.findRelease(releases, graalpyVersion, architecture, true)
|
||||
).toMatchObject({
|
||||
foundAsset: filesRC1,
|
||||
resolvedGraalPyVersion: '23.1.0-a.1'
|
||||
@ -167,7 +137,9 @@ describe('installGraalPy', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
tcFind = jest.spyOn(tc, 'find');
|
||||
tcFind.mockImplementation(() => path.join('GraalPy', '3.6.12', architecture));
|
||||
tcFind.mockImplementation(() =>
|
||||
path.join('GraalPy', '3.6.12', architecture)
|
||||
);
|
||||
|
||||
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
|
||||
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy'));
|
||||
|
327
dist/setup/index.js
vendored
327
dist/setup/index.js
vendored
@ -69091,6 +69091,132 @@ class PoetryCache extends cache_distributor_1.default {
|
||||
exports["default"] = PoetryCache;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8040:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseGraalPyVersion = exports.findGraalPyToolCache = exports.findGraalPyVersion = void 0;
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const graalpyInstall = __importStar(__nccwpck_require__(8265));
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
function findGraalPyVersion(versionSpec, architecture, updateEnvironment, checkLatest, allowPreReleases) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let resolvedGraalPyVersion = '';
|
||||
let installDir;
|
||||
let releases;
|
||||
let graalpyVersionSpec = parseGraalPyVersion(versionSpec);
|
||||
if (checkLatest) {
|
||||
releases = yield graalpyInstall.getAvailableGraalPyVersions();
|
||||
if (releases && releases.length > 0) {
|
||||
const releaseData = graalpyInstall.findRelease(releases, graalpyVersionSpec, architecture, false);
|
||||
if (releaseData) {
|
||||
core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`);
|
||||
graalpyVersionSpec = releaseData.resolvedGraalPyVersion;
|
||||
}
|
||||
else {
|
||||
core.info(`Failed to resolve GraalPy ${graalpyVersionSpec} from manifest`);
|
||||
}
|
||||
}
|
||||
}
|
||||
({ installDir, resolvedGraalPyVersion } = findGraalPyToolCache(graalpyVersionSpec, architecture));
|
||||
if (!installDir) {
|
||||
({ installDir, resolvedGraalPyVersion } = yield graalpyInstall.installGraalPy(graalpyVersionSpec, architecture, allowPreReleases, releases));
|
||||
}
|
||||
const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin';
|
||||
const _binDir = path.join(installDir, pipDir);
|
||||
const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
|
||||
const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`);
|
||||
const pythonLocation = graalpyInstall.getGraalPyBinaryPath(installDir);
|
||||
if (updateEnvironment) {
|
||||
core.exportVariable('pythonLocation', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
||||
core.exportVariable('Python_ROOT_DIR', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
|
||||
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
||||
core.addPath(pythonLocation);
|
||||
core.addPath(_binDir);
|
||||
}
|
||||
core.setOutput('python-version', 'graalpy' + resolvedGraalPyVersion);
|
||||
core.setOutput('python-path', pythonPath);
|
||||
return resolvedGraalPyVersion;
|
||||
});
|
||||
}
|
||||
exports.findGraalPyVersion = findGraalPyVersion;
|
||||
function findGraalPyToolCache(graalpyVersion, architecture) {
|
||||
let resolvedGraalPyVersion = '';
|
||||
let installDir = tc.find('GraalPy', graalpyVersion, architecture);
|
||||
if (installDir) {
|
||||
// 'tc.find' finds tool based on Python version but we also need to check
|
||||
// whether GraalPy version satisfies requested version.
|
||||
resolvedGraalPyVersion = path.basename(path.dirname(installDir));
|
||||
const isGraalPyVersionSatisfies = semver.satisfies(resolvedGraalPyVersion, graalpyVersion);
|
||||
if (!isGraalPyVersionSatisfies) {
|
||||
installDir = null;
|
||||
resolvedGraalPyVersion = '';
|
||||
}
|
||||
}
|
||||
if (!installDir) {
|
||||
core.info(`GraalPy version ${graalpyVersion} was not found in the local cache`);
|
||||
}
|
||||
return { installDir, resolvedGraalPyVersion };
|
||||
}
|
||||
exports.findGraalPyToolCache = findGraalPyToolCache;
|
||||
function parseGraalPyVersion(versionSpec) {
|
||||
const versions = versionSpec.split('-').filter(item => !!item);
|
||||
if (/^(graalpy)(.+)/.test(versions[0])) {
|
||||
const version = versions[0].replace('graalpy', '');
|
||||
versions.splice(0, 1, 'graalpy', version);
|
||||
}
|
||||
if (versions.length < 2 || versions[0] != 'graalpy') {
|
||||
throw new Error("Invalid 'version' property for GraalPy. GraalPy version should be specified as 'graalpy<python-version>' or 'graalpy-<python-version>'. See README for examples and documentation.");
|
||||
}
|
||||
const pythonVersion = versions[1];
|
||||
if (!utils_1.validateVersion(pythonVersion)) {
|
||||
throw new Error("Invalid 'version' property for GraalPy. GraalPy versions should satisfy SemVer notation. See README for examples and documentation.");
|
||||
}
|
||||
return pythonVersion;
|
||||
}
|
||||
exports.parseGraalPyVersion = parseGraalPyVersion;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4003:
|
||||
@ -69419,6 +69545,198 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) {
|
||||
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8265:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.findAsset = exports.getGraalPyBinaryPath = exports.findRelease = exports.graalPyTagToVersion = exports.getAvailableGraalPyVersions = exports.installGraalPy = void 0;
|
||||
const os = __importStar(__nccwpck_require__(2037));
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const httpm = __importStar(__nccwpck_require__(9925));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
function installGraalPy(graalpyVersion, architecture, allowPreReleases, releases) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let downloadDir;
|
||||
releases = releases !== null && releases !== void 0 ? releases : (yield getAvailableGraalPyVersions());
|
||||
if (!releases || releases.length === 0) {
|
||||
throw new Error('No release was found in GraalPy version.json');
|
||||
}
|
||||
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
|
||||
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
|
||||
// check for pre-release
|
||||
core.info([
|
||||
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
|
||||
`Trying pre-release versions`
|
||||
].join(os.EOL));
|
||||
releaseData = findRelease(releases, graalpyVersion, architecture, true);
|
||||
}
|
||||
if (!releaseData || !releaseData.foundAsset) {
|
||||
throw new Error(`GraalPy version ${graalpyVersion} with arch ${architecture} not found`);
|
||||
}
|
||||
const { foundAsset, resolvedGraalPyVersion } = releaseData;
|
||||
const downloadUrl = `${foundAsset.browser_download_url}`;
|
||||
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
|
||||
try {
|
||||
const graalpyPath = yield tc.downloadTool(downloadUrl);
|
||||
core.info('Extracting downloaded archive...');
|
||||
downloadDir = yield 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
|
||||
const archiveName = fs_1.default.readdirSync(downloadDir)[0];
|
||||
const toolDir = path.join(downloadDir, archiveName);
|
||||
let installDir = toolDir;
|
||||
if (!utils_1.isNightlyKeyword(resolvedGraalPyVersion)) {
|
||||
installDir = yield tc.cacheDir(toolDir, 'GraalPy', resolvedGraalPyVersion, architecture);
|
||||
}
|
||||
const binaryPath = getGraalPyBinaryPath(installDir);
|
||||
yield installPip(binaryPath);
|
||||
return { installDir, resolvedGraalPyVersion };
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof Error) {
|
||||
// Rate limit?
|
||||
if (err instanceof tc.HTTPError &&
|
||||
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
|
||||
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
|
||||
}
|
||||
else {
|
||||
core.info(err.message);
|
||||
}
|
||||
if (err.stack !== undefined) {
|
||||
core.debug(err.stack);
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.installGraalPy = installGraalPy;
|
||||
function getAvailableGraalPyVersions() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const url = 'https://api.github.com/repos/oracle/graalpython/releases';
|
||||
const http = new httpm.HttpClient('tool-cache');
|
||||
const response = yield http.getJson(url);
|
||||
if (!response.result) {
|
||||
throw new Error(`Unable to retrieve the list of available GraalPy versions from '${url}'`);
|
||||
}
|
||||
return response.result;
|
||||
});
|
||||
}
|
||||
exports.getAvailableGraalPyVersions = getAvailableGraalPyVersions;
|
||||
function installPip(pythonLocation) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Installing and updating pip');
|
||||
const pythonBinary = path.join(pythonLocation, 'python');
|
||||
yield exec.exec(`${pythonBinary} -m ensurepip`);
|
||||
yield exec.exec(`${pythonLocation}/python -m pip install --ignore-installed pip`);
|
||||
});
|
||||
}
|
||||
function graalPyTagToVersion(tag) {
|
||||
const versionPattern = /.*-(\d+\.\d+\.\d+(?:\.\d+)?)((?:a|b|rc))?(\d*)?/;
|
||||
const match = tag.match(versionPattern);
|
||||
if (match && match[2]) {
|
||||
return `${match[1]}-${match[2]}.${match[3]}`;
|
||||
}
|
||||
else if (match) {
|
||||
return match[1];
|
||||
}
|
||||
else {
|
||||
return tag.replace(/.*-/, '');
|
||||
}
|
||||
}
|
||||
exports.graalPyTagToVersion = graalPyTagToVersion;
|
||||
function findRelease(releases, graalpyVersion, architecture, includePrerelease) {
|
||||
const options = { includePrerelease: includePrerelease };
|
||||
const filterReleases = releases.filter(item => {
|
||||
const isVersionSatisfied = semver.satisfies(graalPyTagToVersion(item.tag_name), graalpyVersion, options);
|
||||
return (isVersionSatisfied && !!findAsset(item, architecture, process.platform));
|
||||
});
|
||||
if (filterReleases.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const sortedReleases = filterReleases.sort((previous, current) => {
|
||||
return (semver.compare(semver.coerce(graalPyTagToVersion(current.tag_name)), semver.coerce(graalPyTagToVersion(previous.tag_name))) ||
|
||||
semver.compare(semver.coerce(graalPyTagToVersion(current.tag_name)), semver.coerce(graalPyTagToVersion(previous.tag_name))));
|
||||
});
|
||||
const foundRelease = sortedReleases[0];
|
||||
const foundAsset = findAsset(foundRelease, architecture, process.platform);
|
||||
return {
|
||||
foundAsset,
|
||||
resolvedGraalPyVersion: graalPyTagToVersion(foundRelease.tag_name)
|
||||
};
|
||||
}
|
||||
exports.findRelease = findRelease;
|
||||
/** Get GraalPy binary location from the tool of installation directory
|
||||
* - On Linux and macOS, the Python interpreter is in 'bin'.
|
||||
* - On Windows, it is in the installation root.
|
||||
*/
|
||||
function getGraalPyBinaryPath(installDir) {
|
||||
const _binDir = path.join(installDir, 'bin');
|
||||
return utils_1.IS_WINDOWS ? installDir : _binDir;
|
||||
}
|
||||
exports.getGraalPyBinaryPath = getGraalPyBinaryPath;
|
||||
function findAsset(item, architecture, platform) {
|
||||
const graalpyArch = architecture === 'x64'
|
||||
? 'amd64'
|
||||
: architecture === 'arm64'
|
||||
? 'aarch64'
|
||||
: architecture;
|
||||
const graalpyPlatform = platform == 'win32' ? 'windows' : platform;
|
||||
if (item.assets) {
|
||||
return item.assets.find((file) => {
|
||||
const match_data = file.name.match('.*(darwin|linux|windows)-(amd64|aarch64).tar.gz$');
|
||||
return (match_data &&
|
||||
match_data[1] === graalpyPlatform &&
|
||||
match_data[2] === graalpyArch);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.findAsset = findAsset;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8168:
|
||||
@ -69804,6 +70122,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const finder = __importStar(__nccwpck_require__(9996));
|
||||
const finderPyPy = __importStar(__nccwpck_require__(4003));
|
||||
const finderGraalPy = __importStar(__nccwpck_require__(8040));
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const os = __importStar(__nccwpck_require__(2037));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
@ -69812,6 +70131,9 @@ const utils_1 = __nccwpck_require__(1314);
|
||||
function isPyPyVersion(versionSpec) {
|
||||
return versionSpec.startsWith('pypy');
|
||||
}
|
||||
function isGraalPyVersion(versionSpec) {
|
||||
return versionSpec.startsWith('graalpy');
|
||||
}
|
||||
function cacheDependencies(cache, pythonVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined;
|
||||
@ -69880,6 +70202,11 @@ function run() {
|
||||
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
||||
core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
|
||||
}
|
||||
else if (isGraalPyVersion(version)) {
|
||||
const installed = yield finderGraalPy.findGraalPyVersion(version, arch, updateEnvironment, checkLatest, allowPreReleases);
|
||||
pythonVersion = `${installed}`;
|
||||
core.info(`Successfully set up GraalPy ${installed}`);
|
||||
}
|
||||
else {
|
||||
if (version.startsWith('2')) {
|
||||
core.warning('The support for python 2.7 will be removed on June 19. Related issue: https://github.com/actions/setup-python/issues/672');
|
||||
|
@ -1,10 +1,6 @@
|
||||
import * as path from 'path';
|
||||
import * as graalpyInstall from './install-graalpy';
|
||||
import {
|
||||
IS_WINDOWS,
|
||||
validateVersion,
|
||||
IGraalPyManifestRelease
|
||||
} from './utils';
|
||||
import {IS_WINDOWS, validateVersion, IGraalPyManifestRelease} from './utils';
|
||||
|
||||
import * as semver from 'semver';
|
||||
import * as core from '@actions/core';
|
||||
@ -34,9 +30,7 @@ export async function findGraalPyVersion(
|
||||
);
|
||||
|
||||
if (releaseData) {
|
||||
core.info(
|
||||
`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`
|
||||
);
|
||||
core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`);
|
||||
graalpyVersionSpec = releaseData.resolvedGraalPyVersion;
|
||||
} else {
|
||||
core.info(
|
||||
@ -52,13 +46,12 @@ export async function findGraalPyVersion(
|
||||
));
|
||||
|
||||
if (!installDir) {
|
||||
({installDir, resolvedGraalPyVersion} =
|
||||
await graalpyInstall.installGraalPy(
|
||||
graalpyVersionSpec,
|
||||
architecture,
|
||||
allowPreReleases,
|
||||
releases
|
||||
));
|
||||
({installDir, resolvedGraalPyVersion} = await graalpyInstall.installGraalPy(
|
||||
graalpyVersionSpec,
|
||||
architecture,
|
||||
allowPreReleases,
|
||||
releases
|
||||
));
|
||||
}
|
||||
|
||||
const pipDir = IS_WINDOWS ? 'Scripts' : 'bin';
|
||||
@ -92,7 +85,11 @@ export function findGraalPyToolCache(
|
||||
architecture: string
|
||||
) {
|
||||
let resolvedGraalPyVersion = '';
|
||||
let installDir: string | null = tc.find('GraalPy', graalpyVersion, architecture);
|
||||
let installDir: string | null = tc.find(
|
||||
'GraalPy',
|
||||
graalpyVersion,
|
||||
architecture
|
||||
);
|
||||
|
||||
if (installDir) {
|
||||
// 'tc.find' finds tool based on Python version but we also need to check
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
IS_WINDOWS,
|
||||
IGraalPyManifestAsset,
|
||||
IGraalPyManifestRelease,
|
||||
isNightlyKeyword,
|
||||
isNightlyKeyword
|
||||
} from './utils';
|
||||
|
||||
export async function installGraalPy(
|
||||
@ -28,12 +28,7 @@ export async function installGraalPy(
|
||||
throw new Error('No release was found in GraalPy version.json');
|
||||
}
|
||||
|
||||
let releaseData = findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
false
|
||||
);
|
||||
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
|
||||
|
||||
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
|
||||
// check for pre-release
|
||||
@ -43,12 +38,7 @@ export async function installGraalPy(
|
||||
`Trying pre-release versions`
|
||||
].join(os.EOL)
|
||||
);
|
||||
releaseData = findRelease(
|
||||
releases,
|
||||
graalpyVersion,
|
||||
architecture,
|
||||
true
|
||||
);
|
||||
releaseData = findRelease(releases, graalpyVersion, architecture, true);
|
||||
}
|
||||
|
||||
if (!releaseData || !releaseData.foundAsset) {
|
||||
@ -157,7 +147,9 @@ export function findRelease(
|
||||
graalpyVersion,
|
||||
options
|
||||
);
|
||||
return isVersionSatisfied && !!findAsset(item, architecture, process.platform);
|
||||
return (
|
||||
isVersionSatisfied && !!findAsset(item, architecture, process.platform)
|
||||
);
|
||||
});
|
||||
|
||||
if (filterReleases.length === 0) {
|
||||
@ -200,15 +192,24 @@ export function findAsset(
|
||||
architecture: string,
|
||||
platform: string
|
||||
) {
|
||||
const graalpyArch = architecture === 'x64' ? 'amd64' : (architecture === 'arm64' ? 'aarch64' : architecture);
|
||||
const graalpyPlatform = platform == "win32" ? "windows" : platform;
|
||||
const graalpyArch =
|
||||
architecture === 'x64'
|
||||
? 'amd64'
|
||||
: architecture === 'arm64'
|
||||
? 'aarch64'
|
||||
: architecture;
|
||||
const graalpyPlatform = platform == 'win32' ? 'windows' : platform;
|
||||
if (item.assets) {
|
||||
return item.assets.find(
|
||||
(file: IGraalPyManifestAsset) => {
|
||||
const match_data = file.name.match(".*(darwin|linux|windows)-(amd64|aarch64).tar.gz$");
|
||||
return match_data && match_data[1] === graalpyPlatform && match_data[2] === graalpyArch;
|
||||
}
|
||||
);
|
||||
return item.assets.find((file: IGraalPyManifestAsset) => {
|
||||
const match_data = file.name.match(
|
||||
'.*(darwin|linux|windows)-(amd64|aarch64).tar.gz$'
|
||||
);
|
||||
return (
|
||||
match_data &&
|
||||
match_data[1] === graalpyPlatform &&
|
||||
match_data[2] === graalpyArch
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -120,9 +120,7 @@ async function run() {
|
||||
allowPreReleases
|
||||
);
|
||||
pythonVersion = `${installed}`;
|
||||
core.info(
|
||||
`Successfully set up GraalPy ${installed}`
|
||||
);
|
||||
core.info(`Successfully set up GraalPy ${installed}`);
|
||||
} else {
|
||||
if (version.startsWith('2')) {
|
||||
core.warning(
|
||||
|
Loading…
Reference in New Issue
Block a user