From 6767fd0bec4e7800f41903af18ad059f2d09a8fc Mon Sep 17 00:00:00 2001 From: AlyonaSviridenko Date: Thu, 8 Apr 2021 17:31:12 +0300 Subject: [PATCH] removed logs, added multiarch support for toolcache --- __tests__/data/pypy.json | 62 ++++++++++++++++++++-------------------- dist/index.js | 11 +++++-- src/find-pypy.ts | 16 ++++++++++- src/install-pypy.ts | 1 - 4 files changed, 55 insertions(+), 35 deletions(-) diff --git a/__tests__/data/pypy.json b/__tests__/data/pypy.json index 8a9922c1..c8889a3b 100644 --- a/__tests__/data/pypy.json +++ b/__tests__/data/pypy.json @@ -96,38 +96,38 @@ "latest_pypy": false, "date": "2021-03-19", "files": [ - { - "filename": "pypy2.7-v7.3.4rc1-aarch64.tar.bz2", - "arch": "aarch64", - "platform": "linux", - "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-aarch64.tar.bz2" - }, - { - "filename": "pypy2.7-v7.3.4rc1-linux32.tar.bz2", - "arch": "i686", - "platform": "linux", - "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-linux32.tar.bz2" - }, - { - "filename": "pypy2.7-v7.3.4rc1-linux64.tar.bz2", - "arch": "x64", - "platform": "linux", - "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-linux64.tar.bz2" - }, - { - "filename": "pypy2.7-v7.3.4rc1-osx64.tar.bz2", - "arch": "x64", - "platform": "darwin", - "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-osx64.tar.bz2" - }, - { - "filename": "pypy2.7-v7.3.4rc1-win64.zip", - "arch": "x64", - "platform": "win64", - "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-win64.zip" - } + { + "filename": "pypy2.7-v7.3.4rc1-aarch64.tar.bz2", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-aarch64.tar.bz2" + }, + { + "filename": "pypy2.7-v7.3.4rc1-linux32.tar.bz2", + "arch": "i686", + "platform": "linux", + "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-linux32.tar.bz2" + }, + { + "filename": "pypy2.7-v7.3.4rc1-linux64.tar.bz2", + "arch": "x64", + "platform": "linux", + "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-linux64.tar.bz2" + }, + { + "filename": "pypy2.7-v7.3.4rc1-osx64.tar.bz2", + "arch": "x64", + "platform": "darwin", + "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-osx64.tar.bz2" + }, + { + "filename": "pypy2.7-v7.3.4rc1-win64.zip", + "arch": "x64", + "platform": "win64", + "download_url": "https://test.downloads.python.org/pypy/pypy2.7-v7.3.4rc1-win64.zip" + } ] - }, + }, { "pypy_version": "7.3.3rc2", "python_version": "3.7.7", diff --git a/dist/index.js b/dist/index.js index 70046715..151dcba4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1133,7 +1133,9 @@ exports.findPyPyVersion = findPyPyVersion; function findPyPyToolCache(pythonVersion, pypyVersion, architecture) { let resolvedPyPyVersion = ''; let resolvedPythonVersion = ''; - let installDir = tc.find('PyPy', pythonVersion, architecture); + let installDir = utils_1.IS_WINDOWS + ? findPyPyInstallDirForWindows(pythonVersion) + : tc.find('PyPy', pythonVersion, architecture); if (installDir) { // 'tc.find' finds tool based on Python version but we also need to check // whether PyPy version satisfies requested version. @@ -1177,6 +1179,12 @@ function parsePyPyVersion(versionSpec) { }; } exports.parsePyPyVersion = parsePyPyVersion; +function findPyPyInstallDirForWindows(pythonVersion) { + let installDir = ''; + utils_1.WINDOWS_ARCHS.forEach(architecture => (installDir = installDir || tc.find('PyPy', pythonVersion, architecture))); + return installDir; +} +exports.findPyPyInstallDirForWindows = findPyPyInstallDirForWindows; /***/ }), @@ -2933,7 +2941,6 @@ function pypyVersionToSemantic(versionSpec) { } exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item) { - core.info(JSON.stringify(item)); return item.files.some((file) => utils_1.WINDOWS_ARCHS.includes(file.arch) && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); } diff --git a/src/find-pypy.ts b/src/find-pypy.ts index 700ce9ee..d809a4f2 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -2,6 +2,7 @@ import * as path from 'path'; import * as pypyInstall from './install-pypy'; import { IS_WINDOWS, + WINDOWS_ARCHS, validateVersion, getPyPyVersionFromPath, readExactPyPyVersionFile, @@ -67,7 +68,9 @@ export function findPyPyToolCache( ) { let resolvedPyPyVersion = ''; let resolvedPythonVersion = ''; - let installDir: string | null = tc.find('PyPy', pythonVersion, architecture); + let installDir: string | null = IS_WINDOWS + ? findPyPyInstallDirForWindows(pythonVersion) + : tc.find('PyPy', pythonVersion, architecture); if (installDir) { // 'tc.find' finds tool based on Python version but we also need to check @@ -129,3 +132,14 @@ export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec { pythonVersion: pythonVersion }; } + +export function findPyPyInstallDirForWindows(pythonVersion: string): string { + let installDir = ''; + + WINDOWS_ARCHS.forEach( + architecture => + (installDir = installDir || tc.find('PyPy', pythonVersion, architecture)) + ); + + return installDir; +} diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 40527515..402525ab 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -195,7 +195,6 @@ export function pypyVersionToSemantic(versionSpec: string) { } export function isArchPresentForWindows(item: any) { - core.info(JSON.stringify(item)); return item.files.some( (file: any) => WINDOWS_ARCHS.includes(file.arch) &&