try to allow pypy3, pypy3.6 or pypy3.7 syntax

This commit is contained in:
mattip 2020-11-09 15:01:27 +02:00
parent 41b7212b16
commit 0ed4f287d5
4 changed files with 30 additions and 20 deletions

24
dist/index.js vendored
View file

@ -6713,12 +6713,12 @@ function binDir(installDir) {
}
}
// Note on the tool cache layout for PyPy:
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
// PyPy has a versioning scheme that uses both an internal version and the python version.
// A particular version of PyPy may contain one or more versions of the Python interpreter.
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
// For example, PyPy 7.3.2 contains Python 2.7, 3.6, and 3.7-alpha.
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
function usePyPy(majorVersion, architecture) {
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
function usePyPy(version, architecture) {
const findPyPy = tc.find.bind(undefined, 'PyPy', version.toString());
let installDir = findPyPy(architecture);
if (!installDir && IS_WINDOWS) {
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
@ -6728,7 +6728,7 @@ function usePyPy(majorVersion, architecture) {
}
if (!installDir) {
// PyPy not installed in $(Agent.ToolsDirectory)
throw new Error(`PyPy ${majorVersion} not found`);
throw new Error(`PyPy ${version} not found`);
}
// For PyPy, Windows uses 'bin', not 'Scripts'.
const _binDir = path.join(installDir, 'bin');
@ -6738,7 +6738,7 @@ function usePyPy(majorVersion, architecture) {
core.exportVariable('pythonLocation', pythonLocation);
core.addPath(installDir);
core.addPath(_binDir);
const impl = 'pypy' + majorVersion.toString();
const impl = 'pypy' + version.toString();
core.setOutput('python-version', impl);
return { impl: impl, version: versionFromPath(installDir) };
}
@ -6818,10 +6818,16 @@ exports.pythonVersionToSemantic = pythonVersionToSemantic;
function findPythonVersion(version, architecture) {
return __awaiter(this, void 0, void 0, function* () {
switch (version.toUpperCase()) {
/* TODO: abstract this out to be more like CPython */
case 'PYPY2':
return usePyPy(2, architecture);
return usePyPy('2', architecture);
case 'PYPY3':
return usePyPy(3, architecture);
case 'PYPY37':
case 'PYPY3.7':
return usePyPy('3.7', architecture);
case 'PYPY36':
case 'PYPY3.6':
return usePyPy('3.6', architecture);
default:
return yield useCpythonVersion(version, architecture);
}
@ -7247,4 +7253,4 @@ exports.exec = exec;
/***/ })
/******/ });
/******/ });