You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,7 @@
6
6
7
7
This action provides the following functionality for GitHub Actions users:
8
8
9
-
- Optionally installing and adding to PATH a version of Python that is already installed in the runner's tool cache.
10
-
- Downloading, installing and adding to PATH an available version of Python from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)) if a specific version is not available in the runner's tool cache.
11
-
- Failing if a specific version of Python is not preinstalled or available for download.
9
+
- Installing a version of Python or PyPy and (by default) adding it to the PATH
12
10
- Optionally caching dependencies for pip, pipenv and poetry
-[Specifying a Python version](advanced-usage.md#specifying-a-python-version)
4
4
-[Specifying a PyPy version](advanced-usage.md#specifying-a-pypy-version)
@@ -17,9 +17,9 @@
17
17
-[macOS](advanced-usage.md#macos)
18
18
-[Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes)
19
19
20
-
# Using python-version input
20
+
##Using the `python-version` input
21
21
22
-
## Specifying a Python version
22
+
###Specifying a Python version
23
23
24
24
If there is a specific version of Python that you need and you don't want to worry about any potential breaking changes due to patch updates (going from `3.7.5` to `3.7.6` for example), you should specify the **exact major, minor, and patch version** (such as `3.7.5`):
25
25
@@ -96,7 +96,7 @@ steps:
96
96
```
97
97
Please refer to the [Advanced range syntax section](https://github.com/npm/node-semver#advanced-range-syntax) of the [semver](https://github.com/npm/node-semver) to check other available range syntaxes.
98
98
99
-
## Specifying a PyPy version
99
+
### Specifying a PyPy version
100
100
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
101
101
The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy version will be used in this case.
102
102
@@ -129,7 +129,7 @@ jobs:
129
129
```
130
130
More details on PyPy syntax can be found in the [Available versions of PyPy](#pypy) section.
131
131
132
-
## Matrix Testing
132
+
###Matrix Testing
133
133
134
134
Using `setup-python` it's possible to use [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
135
135
@@ -176,7 +176,7 @@ jobs:
176
176
run: python --version
177
177
```
178
178
179
-
# Using python-version-file input
179
+
## Using the `python-version-file` input
180
180
181
181
`setup-python`action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.
182
182
@@ -190,7 +190,7 @@ steps:
190
190
python-version-file: '.python-version' # Read python version from a file .python-version
191
191
- run: python my_script.py
192
192
```
193
-
# Check latest version
193
+
## Check latest version
194
194
195
195
The `check-latest` flag defaults to `false`. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific `Python or PyPy` version is always used.
196
196
@@ -208,7 +208,7 @@ steps:
208
208
> Setting `check-latest` to `true` has performance implications as downloading `Python or PyPy` versions is slower than using cached versions.
`setup-python` is able to configure **Python** from two sources:
370
370
@@ -380,7 +380,7 @@ Such a requirement on side-effect could be because you don't want your composite
380
380
381
381
>**Note:** Python versions used in this action are generated in the [python-versions](https://github.com/actions/python-versions) repository. For macOS and Ubuntu images, python versions are built from the source code. For Windows, the python-versions repository uses installation executable. For more information please refer to the [python-versions](https://github.com/actions/python-versions) repository.
382
382
383
-
## PyPy
383
+
###PyPy
384
384
385
385
`setup-python` is able to configure **PyPy** from two sources:
386
386
@@ -394,7 +394,7 @@ Such a requirement on side-effect could be because you don't want your composite
394
394
- PyPy < 7.3.3 are not available to install on-flight.
395
395
- If some versions are not available, you can open an issue in https://foss.heptapod.net/pypy/pypy/
396
396
397
-
# Hosted tool cache
397
+
##Hosted tool cache
398
398
399
399
GitHub hosted runners have a tool cache that comes with a few versions of Python + PyPy already installed. This tool cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of the tool cache with Python and PyPy installed. `setup-python` works by taking a specific version of Python or PyPy from this tool cache and adding it to PATH.
400
400
@@ -409,14 +409,14 @@ GitHub virtual environments are set up in [actions/virtual-environments](https:/
409
409
- Tool cache setup for Windows: [Install-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Install-Toolset.ps1)[Configure-Toolset.ps1](https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Configure-Toolset.ps1)
410
410
411
411
412
-
# Using `setup-python` with a self-hosted runner
412
+
##Using `setup-python` with a self-hosted runner
413
413
414
414
Python distributions are only available for the same [environments](https://github.com/actions/virtual-environments#available-environments) that GitHub Actions hosted environments are available for. If you are using an unsupported version of Ubuntu such as `19.04` or another Linux distribution such as Fedora, `setup-python` may not work.
415
415
416
416
If you have a supported self-hosted runner and you would like to use `setup-python`, there are a few extra things you need to make sure are set up so that new versions of Python can be downloaded and configured on your runner.
417
417
418
418
419
-
## Windows
419
+
###Windows
420
420
421
421
- Your runner needs to be running with administrator privileges so that the appropriate directories and files can be set up when downloading and installing a new version of Python for the first time.
422
422
- If your runner is configured as a service, make sure the account that is running the service has the appropriate write permissions so that Python can get installed. The default `NT AUTHORITY\NETWORK SERVICE` should be sufficient.
@@ -428,7 +428,7 @@ If you have a supported self-hosted runner and you would like to use `setup-pyth
428
428
429
429
>If you are experiencing problems while configuring Python on your self-hosted runner, turn on [step debugging](https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs) to see additional logs.
430
430
431
-
## Linux
431
+
###Linux
432
432
433
433
By default runner downloads and installs tools into the folder set up by `RUNNER_TOOL_CACHE` environment variable. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location for Linux self-hosted runners:
434
434
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/path/to/folder`.
@@ -447,7 +447,7 @@ One quick way to grant access is to change the user and group of the non-default
447
447
> If your runner is configured as a service and you run into problems, make sure the user that the service is running as is correct. For more information, you can [check the status of your self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service#checking-the-status-of-the-service).
448
448
449
449
450
-
## macOS
450
+
###macOS
451
451
452
452
The Python packages for macOS that are downloaded from `actions/python-versions` are originally compiled from the source in `/Users/runner/hostedtoolcache`. Due to the fixed shared library path, these Python packages are non-relocatable and require to be installed only in `/Users/runner/hostedtoolcache`. Before the use of `setup-python` on the macOS self-hosted runner:
453
453
@@ -466,8 +466,8 @@ One quick way to grant access is to change the user and group of `/Users/runner/
466
466
467
467
468
468
469
-
# Using `setup-python` on GHES
469
+
##Using `setup-python` on GHES
470
470
471
471
`setup-python` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Python distributions, `setup-python` downloads distributions from [`actions/python-versions`](https://github.com/actions/python-versions) on github.com (outside of the appliance). These calls to `actions/python-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks like: `##[error]API rate limit exceeded for...`.
472
472
473
-
To avoid hitting rate-limit problems, we recommend [setting up your own runner tool cache](https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access#about-the-included-setup-actions-and-the-runner-tool-cache).
473
+
To avoid hitting rate-limit problems, we recommend [setting up your own runner tool cache](https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access#about-the-included-setup-actions-and-the-runner-tool-cache).
0 commit comments