mirror of
https://github.com/actions/setup-python.git
synced 2026-04-06 09:56:54 +00:00
Users who need custom CPython builds (internal mirrors, GHES-hosted forks, special build configurations, compliance builds, air-gapped runners) could not previously point setup-python at anything other than actions/python-versions. Adds two new inputs: - `mirror`: base URL hosting versions-manifest.json and the Python distributions it references. Defaults to the existing https://raw.githubusercontent.com/actions/python-versions/main. - `mirror-token`: optional token used to authenticate requests to the mirror. If `mirror` is a raw.githubusercontent.com/{owner}/{repo}/{branch} URL, the manifest is fetched via the GitHub REST API (authenticated rate limit applies); otherwise the action falls back to a direct GET of {mirror}/versions-manifest.json. Token interaction ----------------- `token` is never forwarded to arbitrary hosts. Auth resolution is per-URL: 1. if mirror-token is set, use mirror-token 2. else if token is set AND the target host is github.com, *.github.com, or *.githubusercontent.com, use token 3. else send no auth Cases: Default (no inputs set) mirror = default raw.githubusercontent.com URL, mirror-token empty, token = github.token. → manifest API call and tarball downloads use `token`. Identical to prior behavior. Custom raw.githubusercontent.com mirror (e.g. personal fork) mirror-token empty, token = github.token. → manifest API call and tarball downloads use `token` (target hosts are GitHub-owned). Custom non-GitHub mirror, no mirror-token mirror-token empty, token = github.token. → manifest fetched via direct URL (no auth attached), tarball downloads use no auth. `token` is NOT forwarded to the custom host — this is the leak-prevention case. Custom non-GitHub mirror with mirror-token mirror-token set, token may be set. → manifest fetch and tarball downloads use `mirror-token`. Custom GitHub mirror with both tokens set mirror-token wins. Used for both the manifest API call and tarball downloads.
56 lines
3.1 KiB
YAML
56 lines
3.1 KiB
YAML
---
|
|
name: "Setup Python"
|
|
description: "Set up a specific version of Python and add the command-line tools to the PATH."
|
|
author: "GitHub"
|
|
inputs:
|
|
python-version:
|
|
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset."
|
|
python-version-file:
|
|
description: "File containing the Python version to use. Example: .python-version"
|
|
cache:
|
|
description: "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry."
|
|
required: false
|
|
architecture:
|
|
description: "The target architecture (x86, x64, arm64) of the Python or PyPy interpreter."
|
|
check-latest:
|
|
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
|
|
default: false
|
|
token:
|
|
description: "The token used to authenticate when fetching Python distributions from https://github.com/actions/python-versions. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. When 'mirror-token' is set, it takes precedence over this input."
|
|
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
|
mirror:
|
|
description: "Base URL for downloading Python distributions. Defaults to https://raw.githubusercontent.com/actions/python-versions/main. See docs/advanced-usage.md for details."
|
|
default: "https://raw.githubusercontent.com/actions/python-versions/main"
|
|
mirror-token:
|
|
description: "Token used to authenticate requests to 'mirror'. Takes precedence over '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."
|
|
update-environment:
|
|
description: "Set this option if you want the action to update environment variables."
|
|
default: true
|
|
allow-prereleases:
|
|
description: "When 'true', a version range passed to 'python-version' input will match prerelease versions if no GA versions are found. Only 'x.y' version range is supported for CPython."
|
|
default: false
|
|
freethreaded:
|
|
description: "When 'true', use the freethreaded version of Python."
|
|
default: false
|
|
pip-version:
|
|
description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]."
|
|
pip-install:
|
|
description: "Used to specify the packages to install with pip after setting up Python. Can be a requirements file or package names."
|
|
outputs:
|
|
python-version:
|
|
description: "The installed Python or PyPy 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 or PyPy executable."
|
|
runs:
|
|
using: 'node24'
|
|
main: 'dist/setup/index.js'
|
|
post: 'dist/cache-save/index.js'
|
|
post-if: success()
|
|
branding:
|
|
icon: 'code'
|
|
color: 'yellow'
|