From 7a537682efbae1bd87da47928f61dda47678c4d4 Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 5 Dec 2021 15:45:38 +0100 Subject: [PATCH 1/3] added action output python-install-dir * also fixed export of python-version for pypy installs --- action.yml | 2 ++ src/find-pypy.ts | 3 +++ src/find-python.ts | 2 ++ 3 files changed, 7 insertions(+) diff --git a/action.yml b/action.yml index a1dd5b77f..fda811da8 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,8 @@ inputs: outputs: python-version: description: "The installed python version. Useful when given a version range as input." + python-install-dir: + description: "The path where python was installed. (PYTHON_INSTALL_DIR)" runs: using: 'node12' main: 'dist/setup/index.js' diff --git a/src/find-pypy.ts b/src/find-pypy.ts index eb8dfac65..5489105e4 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -53,6 +53,9 @@ export async function findPyPyVersion( core.addPath(pythonLocation); core.addPath(_binDir); + core.setOutput('python-version', resolvedPythonVersion); + core.setOutput('python-install-dir', installDir); + return {resolvedPyPyVersion, resolvedPythonVersion}; } diff --git a/src/find-python.ts b/src/find-python.ts index ff2a20d8d..c6dcbf77f 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -71,6 +71,7 @@ function usePyPy( const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); + core.setOutput('python-install-dir', installDir); return {impl: impl, version: versionFromPath(installDir)}; } @@ -150,6 +151,7 @@ async function useCpythonVersion( const installed = versionFromPath(installDir); core.setOutput('python-version', installed); + core.setOutput('python-install-dir', installDir); return {impl: 'CPython', version: installed}; } From 5445e3ec8fd4568a7d109778d6ae1bc0f3e21dac Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 5 Dec 2021 16:37:52 +0100 Subject: [PATCH 2/3] update details --- README.md | 29 ++++++++++++++++------------- action.yml | 8 ++++++-- package.json | 4 ++-- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3ab7667ee..ed64e9c08 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # setup-python V2

- GitHub Actions status + GitHub Actions status

+This is a fork of https://github.com/actions/setup-python with minor tweaks. +- outputs `python-install-dir` to allow normal use. + This action sets up a Python environment for use in actions by: - optionally installing and adding to PATH a version of Python that is already installed in the tools cache. @@ -29,7 +32,7 @@ Basic: ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified @@ -48,7 +51,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: arBmind/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: x64 @@ -72,7 +75,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v2 + uses: arBmind/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Display Python version @@ -90,7 +93,7 @@ jobs: python-version: ['3.5', '3.6', '3.7.4', '3.8'] steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: arBmind/setup-python@v2 with: python-version: ${{ matrix.python-version }} - run: python my_script.py @@ -100,7 +103,7 @@ Download and set up an accurate pre-release version of Python: ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9.0-beta.4' - run: python my_script.py @@ -110,7 +113,7 @@ Download and set up the latest available version of Python (includes both pre-re ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9.0-alpha - 3.9.0' # SemVer's version range syntax - run: python my_script.py @@ -130,7 +133,7 @@ jobs: - 'pypy-3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3 steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: arBmind/setup-python@v2 with: python-version: ${{ matrix.python-version }} - run: python my_script.py @@ -220,12 +223,12 @@ The action defaults to searching for a dependency file (`requirements.txt` for p The requirements file format allows to specify dependency versions using logical operators (for example chardet>=3.0.4) or specify dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary. -**Caching pip dependencies:** +**Caching pip dependencies:** ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9' cache: 'pip' @@ -239,7 +242,7 @@ steps: - uses: actions/checkout@v2 - name: Install pipenv run: pipx install pipenv -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9' cache: 'pipenv' @@ -251,7 +254,7 @@ steps: ```yaml steps: - uses: actions/checkout@v2 -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9' cache: 'pip' @@ -266,7 +269,7 @@ steps: - uses: actions/checkout@v2 - name: Install pipenv run: pipx install pipenv -- uses: actions/setup-python@v2 +- uses: arBmind/setup-python@v2 with: python-version: '3.9' cache: 'pipenv' diff --git a/action.yml b/action.yml index fda811da8..880823e5b 100644 --- a/action.yml +++ b/action.yml @@ -1,21 +1,25 @@ --- -name: 'Setup Python' +name: 'Setup Python (arBmind)' description: 'Set up a specific version of Python and add the command-line tools to the PATH.' -author: 'GitHub' +author: 'arBmind' inputs: python-version: description: "Version range or exact version of a Python version to use, using SemVer's version range syntax." default: '3.x' + required: true cache: description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv.' required: false architecture: description: 'The target architecture (x86, x64) of the Python interpreter.' + required: false token: description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user. default: ${{ github.token }} + required: false cache-dependency-path: description: 'Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies.' + required: false outputs: python-version: description: "The installed python version. Useful when given a version range as input." diff --git a/package.json b/package.json index 42ae8c69b..033b7ec79 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/actions/setup-python.git" + "url": "git+https://github.com/arBmind/setup-python.git" }, "keywords": [ "actions", "node", "setup" ], - "author": "GitHub", + "author": "arBmind", "license": "MIT", "dependencies": { "@actions/cache": "^1.0.8", From f9580605968b8d19bf8e03ae187b5410a9a2b6ac Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 5 Dec 2021 16:40:27 +0100 Subject: [PATCH 3/3] build release --- dist/setup/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index 321877d9a..3b7b821a5 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -2071,6 +2071,8 @@ function findPyPyVersion(versionSpec, architecture) { core.exportVariable('pythonLocation', pythonLocation); core.addPath(pythonLocation); core.addPath(_binDir); + core.setOutput('python-version', resolvedPythonVersion); + core.setOutput('python-install-dir', installDir); return { resolvedPyPyVersion, resolvedPythonVersion }; }); } @@ -57008,6 +57010,7 @@ function usePyPy(majorVersion, architecture) { } const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); + core.setOutput('python-install-dir', installDir); return { impl: impl, version: versionFromPath(installDir) }; } function useCpythonVersion(version, architecture) { @@ -57056,6 +57059,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-install-dir', installDir); return { impl: 'CPython', version: installed }; }); }