From 0bcf8ef2baf9ecf42f9ef4875f40aedde003bacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 12 Jan 2022 10:35:17 +0100 Subject: [PATCH 1/8] DOC: document -dev syntactic sugar --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1099b3a3..ec831628 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Check out our detailed guide on using [Python with GitHub Actions](https://help. - For every minor version of Python, expect only the latest patch to be preinstalled. - If `3.8.1` is installed for example, and `3.8.2` is released, expect `3.8.1` to be removed and replaced by `3.8.2` in the tools cache. - If the exact patch version doesn't matter to you, specifying just the major and minor version will get you the latest preinstalled patch version. In the previous example, the version spec `3.8` will use the `3.8.2` Python version found in the cache. + - Use `-dev` instead of a patch number (e.g., `3.11-dev`) to install the latest release of a minor version, *alpha and beta releases included*. - Downloadable Python versions from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)). - All available versions are listed in the [version-manifest.json](https://github.com/actions/python-versions/blob/main/versions-manifest.json) file. - If there is a specific version of Python that is not available, you can open an issue here From ac4e85883599916740167aed2c652390762f2cb9 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 29 Apr 2022 09:14:59 +0500 Subject: [PATCH 2/8] Add warning if python version set to empty value --- src/setup-python.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/setup-python.ts b/src/setup-python.ts index 62c76dba..6136237d 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -53,6 +53,10 @@ async function run() { if (cache && isCacheFeatureAvailable()) { await cacheDependencies(cache, pythonVersion); } + } else { + core.warning( + 'python-version is empty, the OS native python will be used' + ); } const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`); From 22daa094b838330a3ab8897dbf26828efd05d952 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 29 Apr 2022 09:29:36 +0500 Subject: [PATCH 3/8] Add generated files --- dist/setup/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index c51a5f77..f5c9fb92 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6112,6 +6112,9 @@ function run() { yield cacheDependencies(cache, pythonVersion); } } + else { + core.warning('python-version is empty, the OS native python will be used'); + } const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`); } From 0b56b76337193b501b7096345a23f23b2590298b Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 29 Apr 2022 12:49:49 +0500 Subject: [PATCH 4/8] Improve wording --- dist/setup/index.js | 2 +- src/setup-python.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index f5c9fb92..367e9ed9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6113,7 +6113,7 @@ function run() { } } else { - core.warning('python-version is empty, the OS native python will be used'); + core.warning("Step input 'python-version' is not set, the OS native python version will be used"); } const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`); diff --git a/src/setup-python.ts b/src/setup-python.ts index 6136237d..25f18b60 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -55,7 +55,7 @@ async function run() { } } else { core.warning( - 'python-version is empty, the OS native python will be used' + "Step input 'python-version' is not set, the OS native python version will be used" ); } const matchersPath = path.join(__dirname, '../..', '.github'); From e31727ce0a67347596370ec677fbc441cfa3ca90 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Wed, 4 May 2022 12:43:58 +0500 Subject: [PATCH 5/8] Improve warning message Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com> --- src/setup-python.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup-python.ts b/src/setup-python.ts index 25f18b60..3584b59a 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -55,7 +55,7 @@ async function run() { } } else { core.warning( - "Step input 'python-version' is not set, the OS native python version will be used" + "The `python-version` input is not set. The version of Python currently in `PATH` will be used." ); } const matchersPath = path.join(__dirname, '../..', '.github'); From 8f73c1495f8947f3553ede54257c5ff89825432b Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Wed, 4 May 2022 12:55:36 +0500 Subject: [PATCH 6/8] Formatting --- dist/setup/index.js | 2 +- src/setup-python.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 367e9ed9..86edc53c 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6113,7 +6113,7 @@ function run() { } } else { - core.warning("Step input 'python-version' is not set, the OS native python version will be used"); + core.warning('The `python-version` input is not set. The version of Python currently in `PATH` will be used.'); } const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`); diff --git a/src/setup-python.ts b/src/setup-python.ts index 3584b59a..14700b7b 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -55,7 +55,7 @@ async function run() { } } else { core.warning( - "The `python-version` input is not set. The version of Python currently in `PATH` will be used." + 'The `python-version` input is not set. The version of Python currently in `PATH` will be used.' ); } const matchersPath = path.join(__dirname, '../..', '.github'); From fff15a21cc8b16191cb1249f621fa3a55b9005b8 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Wed, 18 May 2022 15:20:53 +0200 Subject: [PATCH 7/8] Use pypyX.Y for PyPy python-version input (#349) This versioning scheme is consistent with other tools in the python ecosystem so it feels more natural and allows better interaction with other tools. fixes #346 --- .github/workflows/test-pypy.yml | 4 +++- README.md | 28 ++++++++++++++-------------- __tests__/find-pypy.test.ts | 30 ++++++++++++++++++++++++------ dist/setup/index.js | 8 ++++++-- src/find-pypy.ts | 7 ++++++- src/setup-python.ts | 2 +- 6 files changed, 54 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-pypy.yml b/.github/workflows/test-pypy.yml index f6362069..0eb06c39 100644 --- a/.github/workflows/test-pypy.yml +++ b/.github/workflows/test-pypy.yml @@ -22,6 +22,7 @@ jobs: pypy: - 'pypy-2.7' - 'pypy-3.7' + - 'pypy3.9' - 'pypy-2.7-v7.3.4' - 'pypy-3.7-v7.3.5' - 'pypy-3.7-v7.3.4' @@ -29,6 +30,7 @@ jobs: - 'pypy-3.7-v7.x' - 'pypy-2.7-v7.3.4rc1' - 'pypy-3.7-nightly' + - 'pypy3.8-v7.3.7' steps: - name: Checkout @@ -54,7 +56,7 @@ jobs: - name: Assert expected binaries (or symlinks) are present run: | EXECUTABLE=${{ matrix.pypy }} - EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name + EXECUTABLE=${EXECUTABLE/pypy-/pypy} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe ${EXECUTABLE} --version shell: bash diff --git a/README.md b/README.md index e06082a1..2ace1f7f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '2.x', '3.x', 'pypy-2.7', 'pypy-3.7', 'pypy-3.8' ] + python-version: [ '2.x', '3.x', 'pypy2.7', 'pypy3.7', 'pypy3.8' ] name: Python ${{ matrix.python-version }} sample steps: - uses: actions/checkout@v3 @@ -63,7 +63,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy-2.7', 'pypy-3.8'] + python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy2.7', 'pypy3.8'] exclude: - os: macos-latest python-version: '3.8' @@ -125,9 +125,9 @@ jobs: strategy: matrix: python-version: - - 'pypy-3.7' # the latest available version of PyPy that supports Python 3.7 - - 'pypy-3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3 - - 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8 + - 'pypy3.7' # the latest available version of PyPy that supports Python 3.7 + - 'pypy3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3 + - 'pypy3.8' # the latest available version of PyPy that supports Python 3.8 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 @@ -164,7 +164,7 @@ Check out our detailed guide on using [Python with GitHub Actions](https://help. - Preinstalled versions of PyPy in the tools cache on GitHub-hosted runners - For detailed information regarding the available versions of PyPy that are installed, see [Supported software](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-software). - For the latest PyPy release, all versions of Python are cached. - - Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy-3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy-3.7-v7.3.3`. + - Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy3.7` or `pypy-3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy3.7-v7.3.3` or `pypy-3.7-v7.3.3`. - Downloadable PyPy versions from the [official PyPy site](https://downloads.python.org/pypy/). - All available versions that we can download are listed in [versions.json](https://downloads.python.org/pypy/versions.json) file. @@ -197,17 +197,17 @@ You should specify only a major and minor version if you are okay with the most - Using the most recent patch version will result in a very quick setup since no downloads will be required since a locally installed version Python on the runner will be used. # Specifying a PyPy version -The version of PyPy should be specified in the format `pypy-[-v]`. +The version of PyPy should be specified in the format `pypy[-v]` or `pypy-[-v]`. The `` parameter is optional and can be skipped. The latest version will be used in this case. ``` -pypy-3.7 # the latest available version of PyPy that supports Python 3.7 -pypy-3.8 # the latest available version of PyPy that supports Python 3.8 -pypy-2.7 # the latest available version of PyPy that supports Python 2.7 -pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3 -pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x -pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy -pypy-3.7-nightly # Python 3.7 and nightly PyPy +pypy3.7 or pypy-3.7 # the latest available version of PyPy that supports Python 3.7 +pypy3.8 or pypy-3.8 # the latest available version of PyPy that supports Python 3.8 +pypy2.7 or pypy-2.7 # the latest available version of PyPy that supports Python 2.7 +pypy3.7-v7.3.3 or pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3 +pypy3.7-v7.x or pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x +pypy3.7-v7.3.3rc1 or pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy +pypy3.7-nightly or pypy-3.7-nightly # Python 3.7 and nightly PyPy ``` # Caching packages dependencies diff --git a/__tests__/find-pypy.test.ts b/__tests__/find-pypy.test.ts index ddf7ebcf..8cb32509 100644 --- a/__tests__/find-pypy.test.ts +++ b/__tests__/find-pypy.test.ts @@ -37,16 +37,34 @@ describe('parsePyPyVersion', () => { ['pypy-3.6-v7.x', {pythonVersion: '3.6', pypyVersion: 'v7.x'}], ['pypy-3.6', {pythonVersion: '3.6', pypyVersion: 'x'}], ['pypy-3.6-nightly', {pythonVersion: '3.6', pypyVersion: 'nightly'}], - ['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}] + ['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}], + ['pypy3.8-v7.3.7', {pythonVersion: '3.8', pypyVersion: 'v7.3.7'}], + ['pypy3.8-v7.3.x', {pythonVersion: '3.8', pypyVersion: 'v7.3.x'}], + ['pypy3.8-v7.x', {pythonVersion: '3.8', pypyVersion: 'v7.x'}], + ['pypy3.8', {pythonVersion: '3.8', pypyVersion: 'x'}], + ['pypy3.9-nightly', {pythonVersion: '3.9', pypyVersion: 'nightly'}], + ['pypy3.9-v7.3.8rc1', {pythonVersion: '3.9', pypyVersion: 'v7.3.8-rc.1'}] ])('%s -> %s', (input, expected) => { expect(finder.parsePyPyVersion(input)).toEqual(expected); }); - it('throw on invalid input', () => { - expect(() => finder.parsePyPyVersion('pypy-')).toThrowError( - "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-'. See README for examples and documentation." - ); - }); + it.each(['', 'pypy-', 'pypy', 'p', 'notpypy-'])( + 'throw on invalid input "%s"', + input => { + expect(() => finder.parsePyPyVersion(input)).toThrowError( + "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy' or 'pypy-'. See README for examples and documentation." + ); + } + ); + + it.each(['pypy-2', 'pypy-3', 'pypy2', 'pypy3', 'pypy3.x', 'pypy3.8.10'])( + 'throw on invalid input "%s"', + input => { + expect(() => finder.parsePyPyVersion(input)).toThrowError( + "Invalid format of Python version for PyPy. Python version should be specified in format 'x.y'. See README for examples and documentation." + ); + } + ); }); describe('getPyPyVersionFromPath', () => { diff --git a/dist/setup/index.js b/dist/setup/index.js index 3298e223..bf07395d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6073,7 +6073,7 @@ const os = __importStar(__webpack_require__(87)); const cache_factory_1 = __webpack_require__(633); const utils_1 = __webpack_require__(163); function isPyPyVersion(versionSpec) { - return versionSpec.startsWith('pypy-'); + return versionSpec.startsWith('pypy'); } function cacheDependencies(cache, pythonVersion) { return __awaiter(this, void 0, void 0, function* () { @@ -52411,8 +52411,12 @@ function findPyPyToolCache(pythonVersion, pypyVersion, architecture) { exports.findPyPyToolCache = findPyPyToolCache; function parsePyPyVersion(versionSpec) { const versions = versionSpec.split('-').filter(item => !!item); + if (/^(pypy)(.+)/.test(versions[0])) { + let pythonVersion = versions[0].replace('pypy', ''); + versions.splice(0, 1, 'pypy', pythonVersion); + } if (versions.length < 2 || versions[0] != 'pypy') { - throw new Error("Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-'. See README for examples and documentation."); + throw new Error("Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy' or 'pypy-'. See README for examples and documentation."); } const pythonVersion = versions[1]; let pypyVersion; diff --git a/src/find-pypy.ts b/src/find-pypy.ts index fd273825..5342c649 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -98,9 +98,14 @@ export function findPyPyToolCache( export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec { const versions = versionSpec.split('-').filter(item => !!item); + if (/^(pypy)(.+)/.test(versions[0])) { + let pythonVersion = versions[0].replace('pypy', ''); + versions.splice(0, 1, 'pypy', pythonVersion); + } + if (versions.length < 2 || versions[0] != 'pypy') { throw new Error( - "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-'. See README for examples and documentation." + "Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy' or 'pypy-'. See README for examples and documentation." ); } diff --git a/src/setup-python.ts b/src/setup-python.ts index 82a9207b..e8789de6 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -7,7 +7,7 @@ import {getCacheDistributor} from './cache-distributions/cache-factory'; import {isCacheFeatureAvailable} from './utils'; function isPyPyVersion(versionSpec: string) { - return versionSpec.startsWith('pypy-'); + return versionSpec.startsWith('pypy'); } async function cacheDependencies(cache: string, pythonVersion: string) { From ff706563d754e642609a7008f4568a5386f3e94c Mon Sep 17 00:00:00 2001 From: mayeut Date: Mon, 23 May 2022 20:59:37 +0200 Subject: [PATCH 8/8] feature: add a `python-path` output Expose a `python-path` output containing the chosen Python executable path. --- .github/workflows/test-pypy.yml | 7 ++++++- .github/workflows/test-python.yml | 17 ++++++++++++++++- .github/workflows/workflow.yml | 10 ++++++++++ README.md | 14 ++++++++++++++ __tests__/check-python-path.sh | 14 ++++++++++++++ action.yml | 2 ++ dist/setup/index.js | 9 ++++++++- src/find-pypy.ts | 6 ++++++ src/find-python.ts | 9 ++++++++- 9 files changed, 84 insertions(+), 4 deletions(-) create mode 100755 __tests__/check-python-path.sh diff --git a/.github/workflows/test-pypy.yml b/.github/workflows/test-pypy.yml index 0eb06c39..5f23b213 100644 --- a/.github/workflows/test-pypy.yml +++ b/.github/workflows/test-pypy.yml @@ -37,10 +37,15 @@ jobs: uses: actions/checkout@v2 - name: setup-python ${{ matrix.pypy }} + id: setup-python uses: ./ with: python-version: ${{ matrix.pypy }} - + + - name: Check python-path + run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' + shell: bash + - name: PyPy and Python version run: python --version diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 8f233015..00043f43 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -23,9 +23,14 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: setup default python + - name: setup default python + id: setup-python uses: ./ + - name: Check python-path + run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' + shell: bash + - name: Validate version run: python --version @@ -45,10 +50,15 @@ jobs: uses: actions/checkout@v2 - name: setup-python ${{ matrix.python }} + id: setup-python uses: ./ with: python-version: ${{ matrix.python }} + - name: Check python-path + run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' + shell: bash + - name: Validate version run: | $pythonVersion = (python --version) @@ -74,10 +84,15 @@ jobs: uses: actions/checkout@v2 - name: setup-python 3.9.0-beta.4 + id: setup-python uses: ./ with: python-version: '3.9.0-beta.4' + - name: Check python-path + run: ./__tests__/check-python-path.sh '${{ steps.setup-python.outputs.python-path }}' + shell: bash + - name: Validate version run: | $pythonVersion = (python --version) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index fee5ae79..171e2055 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -89,3 +89,13 @@ jobs: python-version: 3.8.1 - name: Verify 3.8.1 run: python __tests__/verify-python.py 3.8.1 + + - name: Run with setup-python 3.10 + id: cp310 + uses: ./ + with: + python-version: "3.10" + - name: Verify 3.10 + run: python __tests__/verify-python.py 3.10 + - name: Run python-path sample 3.10 + run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version diff --git a/README.md b/README.md index 2ace1f7f..7508d353 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,20 @@ jobs: ``` More details on PyPy syntax and examples of using preview / nightly versions of PyPy can be found in the [Available versions of PyPy](#available-versions-of-pypy) section. +An output is available with the absolute path of the python interpreter executable if you need it: +```yaml +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + id: cp310 + with: + python-version: "3.10" + - run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version +``` + # Getting started with Python + Actions Check out our detailed guide on using [Python with GitHub Actions](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-python-with-github-actions). diff --git a/__tests__/check-python-path.sh b/__tests__/check-python-path.sh new file mode 100755 index 00000000..1ebee798 --- /dev/null +++ b/__tests__/check-python-path.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +PYTHON_PATH="$1" +PATH_EXECUTABLE=$(python -c 'import sys; print(sys.executable)') +PYTHON_PATH_EXECUTABLE=$("${PYTHON_PATH}" -c 'import sys; print(sys.executable)') +if [ "${PATH_EXECUTABLE}" != "${PYTHON_PATH_EXECUTABLE}" ]; then + echo "Executable mismatch." + echo "python in PATH is: ${PATH_EXECUTABLE}" + echo "python-path (${PYTHON_PATH}) is: ${PYTHON_PATH_EXECUTABLE}" + exit 1 +fi +echo "python-path: ${PYTHON_PATH}" diff --git a/action.yml b/action.yml index bda521dd..00c1e5e4 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,8 @@ outputs: description: "The installed python version. Useful when given a version range as input." cache-hit: description: 'A boolean value to indicate a cache entry was found' + python-path: + description: "The absolute path to the Python executable." runs: using: 'node16' main: 'dist/setup/index.js' diff --git a/dist/setup/index.js b/dist/setup/index.js index bf07395d..6c83cfb1 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -52375,12 +52375,15 @@ function findPyPyVersion(versionSpec, architecture) { } const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin'; const _binDir = path.join(installDir, pipDir); + const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : ''; + const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`); const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir); core.exportVariable('pythonLocation', pythonLocation); core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig'); core.addPath(pythonLocation); core.addPath(_binDir); core.setOutput('python-version', 'pypy' + resolvedPyPyVersion.trim()); + core.setOutput('python-path', pythonPath); return { resolvedPyPyVersion, resolvedPythonVersion }; }); } @@ -57027,8 +57030,11 @@ function useCpythonVersion(version, architecture) { core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath); } } + const _binDir = binDir(installDir); + const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : ''; + const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`); core.addPath(installDir); - core.addPath(binDir(installDir)); + core.addPath(_binDir); if (utils_1.IS_WINDOWS) { // Add --user directory // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python//x64/ @@ -57042,6 +57048,7 @@ function useCpythonVersion(version, architecture) { // On Linux and macOS, pip will create the --user directory and add it to PATH as needed. const installed = versionFromPath(installDir); core.setOutput('python-version', installed); + core.setOutput('python-path', pythonPath); return { impl: 'CPython', version: installed }; }); } diff --git a/src/find-pypy.ts b/src/find-pypy.ts index 5342c649..1008ed6e 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -48,12 +48,18 @@ export async function findPyPyVersion( const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; const _binDir = path.join(installDir, pipDir); + const binaryExtension = IS_WINDOWS ? '.exe' : ''; + const pythonPath = path.join( + IS_WINDOWS ? installDir : _binDir, + `python${binaryExtension}` + ); const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir); core.exportVariable('pythonLocation', pythonLocation); core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig'); core.addPath(pythonLocation); core.addPath(_binDir); core.setOutput('python-version', 'pypy' + resolvedPyPyVersion.trim()); + core.setOutput('python-path', pythonPath); return {resolvedPyPyVersion, resolvedPythonVersion}; } diff --git a/src/find-python.ts b/src/find-python.ts index 3959ecf1..0a3dde13 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -83,8 +83,14 @@ export async function useCpythonVersion( } } + const _binDir = binDir(installDir); + const binaryExtension = IS_WINDOWS ? '.exe' : ''; + const pythonPath = path.join( + IS_WINDOWS ? installDir : _binDir, + `python${binaryExtension}` + ); core.addPath(installDir); - core.addPath(binDir(installDir)); + core.addPath(_binDir); if (IS_WINDOWS) { // Add --user directory @@ -106,6 +112,7 @@ export async function useCpythonVersion( const installed = versionFromPath(installDir); core.setOutput('python-version', installed); + core.setOutput('python-path', pythonPath); return {impl: 'CPython', version: installed}; }