2019-12-27 13:08:34 -05:00
---
2022-07-26 14:47:59 +02:00
name : "Setup Python"
description : "Set up a specific version of Python and add the command-line tools to the PATH."
author : "GitHub"
2019-08-20 10:27:52 -04:00
inputs :
python-version :
2022-07-28 09:38:24 +02:00
description : "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset."
2022-06-02 07:37:57 -07:00
python-version-file :
2022-07-13 13:43:28 +02:00
description : "File containing the Python version to use. Example: .python-version"
2021-11-17 13:31:22 +03:00
cache :
2022-07-26 14:47:59 +02:00
description : "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry."
2021-11-17 13:31:22 +03:00
required : false
2019-08-20 10:27:52 -04:00
architecture :
2024-10-24 19:08:22 +05:30
description : "The target architecture (x86, x64, arm64) of the Python or PyPy interpreter."
2022-07-13 13:43:28 +02:00
check-latest :
2022-07-26 14:47:59 +02:00
description : "Set this option if you want the action to check for the latest available version that satisfies the version spec."
2022-07-13 13:43:28 +02:00
default : false
2020-04-29 20:57:02 +03:00
token :
feat: Add `mirror` and `mirror-token` inputs for custom Python distribution sources
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.
2026-04-06 00:59:40 +02:00
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."
2022-08-30 21:02:20 +02:00
default : ${{ github.server_url == 'https://github.com' && github.token || '' }}
feat: Add `mirror` and `mirror-token` inputs for custom Python distribution sources
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.
2026-04-06 00:59:40 +02:00
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
2021-11-17 13:31:22 +03:00
cache-dependency-path :
2022-07-26 14:47:59 +02:00
description : "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies."
2022-06-29 17:00:51 +02:00
update-environment :
2022-07-26 14:47:59 +02:00
description : "Set this option if you want the action to update environment variables."
2022-06-29 17:00:51 +02:00
default : true
2023-01-27 22:19:31 +01:00
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
2025-03-04 17:49:43 -05:00
freethreaded :
description : "When 'true', use the freethreaded version of Python."
default : false
2025-06-20 08:39:35 +05:30
pip-version :
description : "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]."
2025-09-26 08:31:19 +05:30
pip-install :
description : "Used to specify the packages to install with pip after setting up Python. Can be a requirements file or package names."
2020-03-09 08:18:12 +01:00
outputs :
python-version :
2022-07-28 09:38:24 +02:00
description : "The installed Python or PyPy version. Useful when given a version range as input."
2022-04-05 06:57:13 -07:00
cache-hit :
2022-07-26 14:47:59 +02:00
description : "A boolean value to indicate a cache entry was found"
2022-05-23 20:59:37 +02:00
python-path :
2022-07-28 09:38:24 +02:00
description : "The absolute path to the Python or PyPy executable."
2019-08-20 10:27:52 -04:00
runs :
2025-09-04 03:57:37 +01:00
using : 'node24'
2021-11-17 13:31:22 +03:00
main : 'dist/setup/index.js'
post : 'dist/cache-save/index.js'
post-if : success()
2019-11-05 17:12:58 -05:00
branding :
2019-11-06 10:20:01 -05:00
icon : 'code'
2020-03-09 10:31:20 +01:00
color : 'yellow'