From fe5cc5b5b44b6adc5b28c1b057b7ba575ccc897a Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 21 Feb 2022 14:50:31 +0300 Subject: [PATCH 1/4] remove pypy input --- __tests__/finder.test.ts | 8 -------- dist/setup/index.js | 10 +--------- src/find-python.ts | 10 +--------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index 54bf3cf8c..b6ade1342 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -87,12 +87,4 @@ describe('Finder tests', () => { } expect(thrown).toBeTruthy(); }); - - it('Finds PyPy if it is installed', async () => { - const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); - await io.mkdirP(pythonDir); - fs.writeFileSync(`${pythonDir}.complete`, 'hello'); - // This will throw if it doesn't find it in the cache (because no such version exists) - await finder.findPythonVersion('pypy2', 'x64'); - }); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index a742d5880..d8607004a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -57135,15 +57135,7 @@ function pythonVersionToSemantic(versionSpec) { exports.pythonVersionToSemantic = pythonVersionToSemantic; function findPythonVersion(version, architecture) { return __awaiter(this, void 0, void 0, function* () { - switch (version.toUpperCase()) { - case 'PYPY2': - return usePyPy('2', architecture); - case 'PYPY3': - // keep pypy3 pointing to 3.6 for backward compatibility - return usePyPy('3.6', architecture); - default: - return yield useCpythonVersion(version, architecture); - } + return yield useCpythonVersion(version, architecture); }); } exports.findPythonVersion = findPythonVersion; diff --git a/src/find-python.ts b/src/find-python.ts index ff2a20d8d..f0feed62e 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -191,13 +191,5 @@ export async function findPythonVersion( version: string, architecture: string ): Promise { - switch (version.toUpperCase()) { - case 'PYPY2': - return usePyPy('2', architecture); - case 'PYPY3': - // keep pypy3 pointing to 3.6 for backward compatibility - return usePyPy('3.6', architecture); - default: - return await useCpythonVersion(version, architecture); - } + return await useCpythonVersion(version, architecture); } From ee6a186a78b64ad49e596c9f365494660509dbe9 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 21 Feb 2022 15:11:27 +0300 Subject: [PATCH 2/4] remove setup-pypy-legacy --- .github/workflows/test-python.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 191db1411..8f2330152 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -91,23 +91,3 @@ jobs: - name: Run simple code run: python -c 'import math; print(math.factorial(5))' - setup-pypy-legacy: - name: Setup PyPy ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-10.15, windows-2019, ubuntu-18.04, ubuntu-20.04] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: setup-python pypy3 - uses: ./ - with: - python-version: 'pypy3' - - - name: setup-python pypy2 - uses: ./ - with: - python-version: 'pypy2' From 44f86dea75b6fd0eee5b8ea7a79ad7fafbfd8649 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 22 Feb 2022 11:55:20 +0300 Subject: [PATCH 3/4] fix comments --- __tests__/finder.test.ts | 8 +++--- dist/setup/index.js | 43 ++------------------------------ src/find-python.ts | 54 +--------------------------------------- src/setup-python.ts | 2 +- 4 files changed, 8 insertions(+), 99 deletions(-) diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index b6ade1342..d48056964 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -35,7 +35,7 @@ describe('Finder tests', () => { await io.mkdirP(pythonDir); fs.writeFileSync(`${pythonDir}.complete`, 'hello'); // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) - await finder.findPythonVersion('3.x', 'x64'); + await finder.useCpythonVersion('3.x', 'x64'); }); it('Finds stable Python version if it is not installed, but exists in the manifest', async () => { @@ -52,7 +52,7 @@ describe('Finder tests', () => { fs.writeFileSync(`${pythonDir}.complete`, 'hello'); }); // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) - await finder.findPythonVersion('1.2.3', 'x64'); + await finder.useCpythonVersion('1.2.3', 'x64'); }); it('Finds pre-release Python version in the manifest', async () => { @@ -74,14 +74,14 @@ describe('Finder tests', () => { fs.writeFileSync(`${pythonDir}.complete`, 'hello'); }); // This will throw if it doesn't find it in the manifest (because no such version exists) - await finder.findPythonVersion('1.2.3-beta.2', 'x64'); + await finder.useCpythonVersion('1.2.3-beta.2', 'x64'); }); it('Errors if Python is not installed', async () => { // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) let thrown = false; try { - await finder.findPythonVersion('3.300000', 'x64'); + await finder.useCpythonVersion('3.300000', 'x64'); } catch { thrown = true; } diff --git a/dist/setup/index.js b/dist/setup/index.js index d8607004a..032fccc9d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6656,7 +6656,7 @@ function run() { core.info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`); } else { - const installed = yield finder.findPythonVersion(version, arch); + const installed = yield finder.useCpythonVersion(version, arch); pythonVersion = installed.version; core.info(`Successfully setup ${installed.impl} (${pythonVersion})`); } @@ -57024,40 +57024,6 @@ function binDir(installDir) { return path.join(installDir, 'bin'); } } -// Note on the tool cache layout for PyPy: -// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme. -// 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. -// 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); - let installDir = findPyPy(architecture); - if (!installDir && utils_1.IS_WINDOWS) { - // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64. - // On our Windows virtual environments, we only install an x86 version. - // Fall back to x86. - installDir = findPyPy('x86'); - } - if (!installDir) { - // PyPy not installed in $(Agent.ToolsDirectory) - throw new Error(`PyPy ${majorVersion} not found`); - } - // For PyPy, Windows uses 'bin', not 'Scripts'. - const _binDir = path.join(installDir, 'bin'); - // On Linux and macOS, the Python interpreter is in 'bin'. - // On Windows, it is in the installation root. - const pythonLocation = utils_1.IS_WINDOWS ? installDir : _binDir; - core.exportVariable('pythonLocation', pythonLocation); - core.addPath(installDir); - core.addPath(_binDir); - // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. - if (utils_1.IS_WINDOWS) { - core.addPath(path.join(installDir, 'Scripts')); - } - const impl = 'pypy' + majorVersion.toString(); - core.setOutput('python-version', impl); - return { impl: impl, version: versionFromPath(installDir) }; -} function useCpythonVersion(version, architecture) { return __awaiter(this, void 0, void 0, function* () { const desugaredVersionSpec = desugarDevVersion(version); @@ -57107,6 +57073,7 @@ function useCpythonVersion(version, architecture) { return { impl: 'CPython', version: installed }; }); } +exports.useCpythonVersion = useCpythonVersion; /** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */ function desugarDevVersion(versionSpec) { if (versionSpec.endsWith('-dev')) { @@ -57133,12 +57100,6 @@ function pythonVersionToSemantic(versionSpec) { return versionSpec.replace(prereleaseVersion, '$1-$2'); } exports.pythonVersionToSemantic = pythonVersionToSemantic; -function findPythonVersion(version, architecture) { - return __awaiter(this, void 0, void 0, function* () { - return yield useCpythonVersion(version, architecture); - }); -} -exports.findPythonVersion = findPythonVersion; /***/ }), diff --git a/src/find-python.ts b/src/find-python.ts index f0feed62e..b8175a436 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -30,52 +30,7 @@ function binDir(installDir: string): string { } } -// Note on the tool cache layout for PyPy: -// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme. -// 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. -// We only care about the Python version, so we don't use the PyPy version for the tool cache. -function usePyPy( - majorVersion: '2' | '3.6', - architecture: string -): InstalledVersion { - const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion); - let installDir: string | null = findPyPy(architecture); - - if (!installDir && IS_WINDOWS) { - // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64. - // On our Windows virtual environments, we only install an x86 version. - // Fall back to x86. - installDir = findPyPy('x86'); - } - - if (!installDir) { - // PyPy not installed in $(Agent.ToolsDirectory) - throw new Error(`PyPy ${majorVersion} not found`); - } - - // For PyPy, Windows uses 'bin', not 'Scripts'. - const _binDir = path.join(installDir, 'bin'); - - // On Linux and macOS, the Python interpreter is in 'bin'. - // On Windows, it is in the installation root. - const pythonLocation = IS_WINDOWS ? installDir : _binDir; - core.exportVariable('pythonLocation', pythonLocation); - - core.addPath(installDir); - core.addPath(_binDir); - // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. - if (IS_WINDOWS) { - core.addPath(path.join(installDir, 'Scripts')); - } - - const impl = 'pypy' + majorVersion.toString(); - core.setOutput('python-version', impl); - - return {impl: impl, version: versionFromPath(installDir)}; -} - -async function useCpythonVersion( +export async function useCpythonVersion( version: string, architecture: string ): Promise { @@ -186,10 +141,3 @@ export function pythonVersionToSemantic(versionSpec: string) { const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g; return versionSpec.replace(prereleaseVersion, '$1-$2'); } - -export async function findPythonVersion( - version: string, - architecture: string -): Promise { - return await useCpythonVersion(version, architecture); -} diff --git a/src/setup-python.ts b/src/setup-python.ts index 3a19efe13..b37d58356 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -37,7 +37,7 @@ async function run() { `Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})` ); } else { - const installed = await finder.findPythonVersion(version, arch); + const installed = await finder.useCpythonVersion(version, arch); pythonVersion = installed.version; core.info(`Successfully setup ${installed.impl} (${pythonVersion})`); } From 84edb6bbc1b9d6f7ca7d6d7e09d32eb05dbe81fc Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 25 Feb 2022 14:16:01 +0300 Subject: [PATCH 4/4] change npm install to npm ci --- .github/workflows/workflow.yml | 4 ++-- dist/setup/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b5db2f45a..5c8d54032 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,8 +24,8 @@ jobs: with: node-version: 16.x - - name: npm install - run: npm install + - name: npm ci + run: npm ci - name: Lint run: npm run format-check diff --git a/dist/setup/index.js b/dist/setup/index.js index f9709b8f0..ae0ab4045 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -57111,7 +57111,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.findPythonVersion = exports.pythonVersionToSemantic = void 0; +exports.pythonVersionToSemantic = exports.useCpythonVersion = void 0; const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); const utils_1 = __webpack_require__(163); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy