Commit Graph
64 Commits
Author SHA1 Message Date
Ludovic HenryandClaude Opus 4.8 337b0725b8 feat: Add mirror and mirror-token inputs for custom Python distribution sources (#1302)
* 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.

* fix: address mirror review feedback

- scope mirror-token to the mirror host and send it verbatim
- route non-repo mirrors straight to the URL fetch instead of throwing
- authenticate the manifest fetch
- warn on slash branches, and on mirror with PyPy/GraalPy
- memoize mirror validation
- exercise the direct-URL path in the E2E job

Addresses https://github.com/actions/setup-python/pull/1302#issuecomment-5202618946

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix: correct mirror warnings, auth scoping, and integration coverage

- only warn about PyPy/GraalPy mirror when a custom mirror is set; the
  action.yml default made the warning fire on every run
- accept the refs/heads/{branch} raw URL form so it routes via the REST
  API instead of tripping the slash-branch warning
- scope mirror-token to the full mirror origin (scheme+host+port) so it
  can't leak to a same-host http download_url
- make an invalid mirror fatal on the auth path, matching getManifestUrl
- fix warning/docs that wrongly claimed the raw fallback is anonymous
- force a manifest fetch in the mirror integration job (check-latest) so
  it actually contacts the mirror instead of using the preinstalled cache

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 17:31:48 -05:00
gowridurgadandgowridurgad 0f3a009f47 Remove the pip-install input (#1336)
* Remove the pip-install input

* Resloves merge conflicts

---------

Co-authored-by: gowridurgad <gowridurgad@gmail.com>
2026-07-16 09:59:13 -05:00
Priya Gupta f8cf4291c8 Migrate to ESM and upgrade dependencies (#1330)
* Migrate to ESM and upgrade dependencies

* Add ESM migration note to README for V7

* Remove unnecessary devDependencies: ts-node, @types/jest

* npm audit fix

* Upgrade @types/node to version 26.0.0

* Clarify ESM migration details in README for V7

* Update README and dependencies

* Fix lint issue
2026-07-15 11:40:44 -05:00
gowridurgadand“gowridurgad” 2e3e4b15a8 Add support for pip-install input (#1201)
* Add pip-install input

* Improve error message

* Logic update

---------

Co-authored-by: “gowridurgad” <“hgowridurgad@github.com>
2025-09-25 22:01:19 -05:00
aparnajyothi-yandHaritha 3d1e2d2ca0 Revert "Enhance cache-dependency-path handling to support files outside the workspace root" (#1186)
* Revert "Enhance cache-dependency-path handling to support files outside the w…"

This reverts commit 1264885983.

* pckage.json version update

---------

Co-authored-by: Haritha <73516759+HarithaVattikuti@users.noreply.github.com>
2025-08-28 13:30:09 -05:00
aparnajyothi-y 1264885983 Enhance cache-dependency-path handling to support files outside the workspace root (#1128)
* ehnace cache dependency path handling

* logic update

* npm run format-check

* update cacheDependencies tests to cover resolved paths and copy edge cases

* check failure fix

* depricate-windows-2019

* refactored the code

* Check failure fix
2025-06-24 23:40:44 -05:00
Kryštof Korb 5db1cf9a59 Enhance reading from .python-version (#787)
* Enhance reading from .python-version

* Fix typos

* Fix lint

* Add built files

* Don't use EOL versions in `utils.test.ts`

* Fix Prettier

* Don't use unreleased versions in `utils.test.ts`

* Update versions in `utils.test.ts` again
2025-05-21 16:19:28 -05:00
Sam Gross 9e62be81b2 Support free threaded Python versions like '3.13t' (#973)
* Support free threaded Python versions like '3.13t'

Python wheels, pyenv, and a number of other tools use 't' in the Python
version number to identify free threaded builds. For example, '3.13t',
'3.14.0a1', '3.14t-dev'.

This PR supports that syntax in `actions/setup-python`, strips the "t",
and adds "-freethreading" to the architecture to select the correct
Python version.

See #771

* Add free threading to advanced usage documentation

* Fix desugaring of `3.13.1t` and add test case.

* Add freethreaded input and fix handling of prerelease versions

* Fix lint

* Add 't' suffix to python-version output

* Use distinct cache key for free threaded Python

* Remove support for syntax like '3.14.0a1'

* Clarify use of 't' suffix

* Improve error message when trying to use free threaded Python versions before 3.13
2025-03-04 16:49:43 -06:00
Jeff Widman 8635b1ccc5 Change deprecation comment to past tense (#723) 2023-10-16 11:19:29 +02:00
Tim FelgentreffandMichael Simacek 5f2af211d6 Add GraalPy support (#694)
* Add support for graalpy

* add graalpy test workflow

* format, lint and build

* symlink graalpy binaries names

* fix macos names for graalpy

* Don't attempt to update pip for graalpy

* Remove test schedule

* Extract common getBinaryDirectory function for PyPy and GraalPy

* Clean up and format

* Pass GitHub token to GraalPy queries

* Utilize pagination when querying GraalPy GitHub releases

* Build

* Fix lint errors

* Deal with possible multiple artifacts for a single releases

* Skip few GraalPy tests on windows - we don't have a windows release yet

* Fix GraalPy test on Mac OS

* Build

* Skip one more GraalPy test on windows

---------

Co-authored-by: Michael Simacek <michael.simacek@oracle.com>
2023-10-10 14:59:54 +02:00
Dario Curreri 0d5da6a89a Read python version from pyproject.toml (fix #542) (#669) 2023-06-28 22:02:44 +02:00
Dmitry Shibanov bd6b4b6205 Add warning for python 2.7 (#673) 2023-05-24 14:37:35 +02:00
Ivan ec365b4eba Add and configure ESLint and update configuration for Prettier (#617)
* Add ESLint, update Prettier

* Update docs

* Update tests

* Update licenses

* Fix review points
2023-03-09 12:44:56 +02:00
Matthieu Darbois 2652534ead feature: fallback to pre-release when no stable version is found (#414)
This allows to specify version like `3.11` or `pypy3.10` in workflows before those versions are released.
This lessen the burden for users of `setup-python` by not having to modify their workflow twice: once when a pre-release is available (e.g. `3.11-dev`) and once when the first stable release is published (e.g. `3.11`)
2023-01-27 16:19:31 -05:00
Dmitry Shibanov 5ccb29d877 Install multiple python versions (#567) 2022-12-22 13:02:09 +01:00
Leon Wright 7e39d25e3f refactor: Debug message for Python installation path 2022-07-26 20:40:49 +08:00
Leon Wright bc8ee42330 fix: Mac Toolpath
Shared libraries for the Mac python builds are not configured with the
relocatable flag, thus must always be configured with the hosted path.

Relates #459
2022-07-26 19:40:29 +08:00
Leon Wright 467a981225 feat: Add 'IS_MAC' util 2022-07-26 19:38:18 +08:00
Leon Wright 9f1915a970 fix: Self-Hosted Tool Cache
This fixes the tool cache path for self-hosted runners, along
with handling AGENT_TOOLSDIRECTORY for both hosted + self-hosted.

    Fixes actions#459
2022-07-26 19:37:39 +08:00
Dmitry Shibanov 2f06e9da25 Add check-latest functionality (#406) 2022-07-25 16:54:04 +02:00
Dmitry Shibanov 49a521fa06 Fix poetry version (#445) 2022-07-25 15:02:06 +02:00
IvanZosimov b88a682917 Fix resolveVersionInput() logic 2022-07-15 16:52:20 +02:00
Marko Zivic 364e819741 Merge pull request #394 from akv-platform/v-sedoli/set-env-by-default
Assign default value of AGENT_TOOLSDIRECTORY if not set
2022-07-04 10:35:46 +02:00
IvanZosimov 099ed898be Optimize code 2022-06-30 18:42:04 +02:00
IvanZosimov ccb7da8ae9 Change warning handler to default 2022-06-30 18:28:17 +02:00
IvanZosimov 5fbb819407 Optimize logic, rebuild action 2022-06-30 17:32:12 +02:00
IvanZosimov 82eddc4023 Add warning in case the versionFile isn't found 2022-06-30 16:34:29 +02:00
IvanZosimov d97b6edda3 Fix typos 2022-06-30 16:25:46 +02:00
IvanZosimov 84087f5301 Rearrange logic 2022-06-30 16:21:14 +02:00
IvanZosimov 56f6060254 Fix naming 2022-06-30 14:41:09 +02:00
IvanZosimov 6733fc44ec Fix typo 2022-06-30 13:44:10 +02:00
IvanZosimov afd3e72a25 Fix bug in resolveVersionInput() 2022-06-30 13:38:43 +02:00
Matthieu Darbois 00a5248c77 feature: add update-environment input (#411)
This option allows to specify if the action shall update environment variables (default) or not.
This allows to use the setup-python action in a composite action without side effect (except downloading/installing python if version is missing).
2022-06-29 11:00:51 -04:00
Sergey Dolin 958897304a Exclude windows from the fix 2022-06-29 11:22:07 +02:00
Sergey Dolin 5d9fdcab75 Handle each OS in its own way 2022-06-29 11:22:07 +02:00
Sergey Dolin a8da2a66aa Use /opt/hostedtoolcache as default value AGENT_TOOLSDIRECTORY 2022-06-29 11:21:21 +02:00
Kurt von Laven ffcd00020c Allow python-version-file to be a relative path (#431) 2022-06-20 16:04:59 +02:00
Andrew DiLosa 53e15292cd add support for python-version-file (#336)
* add support for python-version-file

* Update action.yml

* update to v4, remove python-version default

* python-version overrides python-version-file, like setup-node
* checks '.python-version' by default if nothing else specified

* update tests, update to checkout@v3

* update build

* appease the linter

* remove old test for default python version

* revert readme changes

* update build
2022-06-02 16:37:57 +02:00
Matthieu Darbois fff15a21cc 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
2022-05-18 15:20:53 +02:00
Marko Zivic fd8f0a9fb8 Merge pull request #396 from akv-platform/v-sedoli/issue-241
Add warning if python version set to empty value
2022-05-04 15:21:43 +02:00
Sergey Dolin 8f73c1495f Formatting 2022-05-04 12:55:36 +05:00
Sergey DolinandBrian Cristante e31727ce0a Improve warning message
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2022-05-04 12:43:58 +05:00
Brian Cristante a69041ca9f Successfully set up (#399) 2022-05-03 08:43:53 -04:00
Sergey Dolin 0b56b76337 Improve wording 2022-04-29 12:49:49 +05:00
Sergey Dolin ac4e858835 Add warning if python version set to empty value 2022-04-29 09:14:59 +05:00
Dmitry Shibanov c36dc43e7b Fix conflicts (#389) 2022-04-26 16:50:29 +02:00
Sergey Dolin bcc31375e1 Throw exe on empty python-version 2022-04-21 08:19:23 +05:00
Sergey Dolin f4b66dec00 Merge branch 'actions:main' into main 2022-04-06 12:51:31 +05:00
Shubham TiwariandBrian Cristante 05fb98de9a Cache on ghes (#363)
* initial changes

* updated version

* format check

* refactored code

* updated test cases

* Update src/utils.ts

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>

* Update utils.ts

* Update utils.test.ts

* review comments

* dist update

* Review comment

* update version

* updated version

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2022-03-31 15:11:27 -04:00
Dmitry Shibanov 0ebf233433 Remove legacy PyPy input (#342) 2022-02-28 10:19:48 +03:00