diff --git a/README.md b/README.md index f9ee8a6b..a3080367 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '2.x', '3.x', 'pypy2', 'pypy3' ] + python-version: [ '2.x', '3.x', 'pypy2', 'pypy3.7' ] name: Python ${{ matrix.python-version }} sample steps: - uses: actions/checkout@v2 @@ -60,7 +60,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3] + python-version: [2.7, 3.6, 3.7, 3.8, pypy2, pypy3.7] exclude: - os: macos-latest python-version: 3.8 diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index 54bf3cf8..1eceb518 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -89,10 +89,10 @@ describe('Finder tests', () => { }); it('Finds PyPy if it is installed', async () => { - const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); + const pythonDir: string = path.join(toolDir, 'PyPy', '3.7.4', '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'); + await finder.findPythonVersion('pypy3', 'x64'); }); }); diff --git a/dist/index.js b/dist/index.js index 7fa762a1..6c7f8462 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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; /***/ }) -/******/ }); \ No newline at end of file +/******/ }); diff --git a/src/find-python.ts b/src/find-python.ts index 8bc8d5bc..7e2074ed 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -33,12 +33,12 @@ 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. +// 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: 2 | 3, architecture: string): InstalledVersion { - const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString()); +function usePyPy(version: string, architecture: string): InstalledVersion { + const findPyPy = tc.find.bind(undefined, 'PyPy', version.toString()); let installDir: string | null = findPyPy(architecture); if (!installDir && IS_WINDOWS) { @@ -50,7 +50,7 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion { 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'. @@ -64,7 +64,7 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): InstalledVersion { 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)}; @@ -187,10 +187,14 @@ export async function findPythonVersion( architecture: string ): Promise { switch (version.toUpperCase()) { + /* TODO: extract this into a function */ case 'PYPY2': return usePyPy(2, architecture); + case 'PYPY3.6': + return usePyPy(3.6, architecture); case 'PYPY3': - return usePyPy(3, architecture); + case 'PYPY3.7': + return usePyPy(3.7, architecture); default: return await useCpythonVersion(version, architecture); }