From cb9573b913b94894201cf129d7f50fe1997881fb Mon Sep 17 00:00:00 2001 From: AlyonaSviridenko Date: Thu, 8 Apr 2021 16:00:25 +0300 Subject: [PATCH] test for pypy new version notation --- .github/workflows/test-pypy.yml | 6 +----- src/find-pypy.ts | 4 ++-- src/install-pypy.ts | 19 +++++++++++++++---- src/utils.ts | 2 ++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-pypy.yml b/.github/workflows/test-pypy.yml index 4041440d..bd06e578 100644 --- a/.github/workflows/test-pypy.yml +++ b/.github/workflows/test-pypy.yml @@ -23,13 +23,9 @@ jobs: - 'pypy-2.7' - 'pypy-3.6' - 'pypy-3.7' - - 'pypy-2.7-v7.3.2' - - 'pypy-3.6-v7.3.2' - - 'pypy-3.7-v7.3.2' - - 'pypy-3.6-v7.3.x' - - 'pypy-3.7-v7.x' - 'pypy-3.6-v7.3.3rc1' - 'pypy-3.7-nightly' + - 'pypy-2.7-v7.3.4rc1' steps: - name: Checkout diff --git a/src/find-pypy.ts b/src/find-pypy.ts index 700ce9ee..850311dd 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -28,9 +28,9 @@ export async function findPyPyVersion( const pypyVersionSpec = parsePyPyVersion(versionSpec); // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64. - if (IS_WINDOWS && architecture === 'x64') { + /*if (IS_WINDOWS && architecture === 'x64') { architecture = 'x86'; - } + }*/ ({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache( pypyVersionSpec.pythonVersion, diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 99d60300..f2ab85ae 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -8,6 +8,8 @@ import fs from 'fs'; import { IS_WINDOWS, + WINDOWS_ARCHS, + WINDOWS_PLATFORMS, IPyPyManifestRelease, createSymlinkInFolder, isNightlyKeyword, @@ -142,10 +144,7 @@ export function findRelease( isPyPyNightly || semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion); const isArchPresent = - item.files && - item.files.some( - file => file.arch === architecture && file.platform === process.platform - ); + item.files && (IS_WINDOWS ? isArchPresentForWindows(item) : isArchPresentForMacOrLinux(item, architecture, process.platform)); return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent; }); @@ -191,3 +190,15 @@ export function pypyVersionToSemantic(versionSpec: string) { const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc))(\d*)/g; return versionSpec.replace(prereleaseVersion, '$1-$2.$3'); } + +export function isArchPresentForWindows(item: any) { + return item.files.some( + file => WINDOWS_ARCHS.includes(file.arch) && WINDOWS_PLATFORMS.includes( file.platform) + ); +} + +export function isArchPresentForMacOrLinux(item: any, architecture: string, platform: string) { + return item.files.some( + file => file.arch === architecture && file.platform === platform + ); +} diff --git a/src/utils.ts b/src/utils.ts index e96d5b23..c15fe3d0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,6 +4,8 @@ import * as semver from 'semver'; export const IS_WINDOWS = process.platform === 'win32'; export const IS_LINUX = process.platform === 'linux'; +export const WINDOWS_ARCHS = ['x86', 'x64']; +export const WINDOWS_PLATFORMS = ['win32', 'win64']; const PYPY_VERSION_FILE = 'PYPY_VERSION'; export interface IPyPyManifestAsset {