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
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ This action provides the following functionality for GitHub Actions users:
24
24
25
25
See [action.yml](action.yml)
26
26
27
+
**Python**
27
28
```yaml
28
29
steps:
29
30
- uses: actions/checkout@v3
@@ -32,6 +33,16 @@ steps:
32
33
python-version: '3.10'
33
34
- run: python my_script.py
34
35
```
36
+
37
+
**PyPy**
38
+
```yaml
39
+
steps:
40
+
- uses: actions/checkout@v3
41
+
- uses: actions/setup-python@v4
42
+
with:
43
+
python-version: 'pypy3.7'
44
+
- run: python my_script.py
45
+
```
35
46
The `python-version` input is optional. If not supplied, the Python/PyPy version from the PATH will be used. The default version of Python/PyPy in PATH vary between runners and can be changed unexpectedly so we recommend always use `setup-python`.
36
47
37
48
The action will first check the local [tool cache](docs/advanced-usage.md#hosted-tool-cache) for a [semver](https://github.com/npm/node-semver#versions) match. If unable to find a specific version in the tool cache, the action will attempt to download a version of Python from [GitHub Releases](https://github.com/actions/python-versions/releases) and for PyPy from the official [PyPy's dist](https://downloads.python.org/pypy/).
@@ -40,11 +51,11 @@ For information regarding locally cached versions of Python/PyPy on GitHub hoste
40
51
41
52
## Supported version syntax
42
53
43
-
The `python-version` input supports the [Semantic Versioning Specification](https://github.com/npm/node-semver#versions) and some special version notations (e.g. `x.y-dev`), for detailed examples please refer to the section: [Using python-version input](docs/advanced-usage.md#using-python-version-input) of the [Advanced usage](docs/advanced-usage.md) guide.
54
+
The `python-version` input supports the [Semantic Versioning Specification](https://semver.org/) and some special version notations (e.g. `semver ranges`, `x.y-dev syntax`, etc), for detailed examples please refer to the section: [Using python-version input](docs/advanced-usage.md#using-python-version-input) of the [Advanced usage](docs/advanced-usage.md) guide.
44
55
45
56
## Supported architectures
46
57
47
-
Using `architecture` input it's possible to specify required python's interpreter architecture: `x86`or `x64`. If input is not specified it defaults to `x64`.
58
+
Using `architecture` input it's possible to specify required python's interpreter architecture: `x86`or `x64`. If input is not specified the architecture defaults to `x64`.
Copy file name to clipboardExpand all lines: docs/advanced-usage.md
+38-23Lines changed: 38 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ steps:
36
36
- The only downside to this is that set up will take a little longer since the exact version will have to be downloaded if the exact version is not already installed on the runner due to more recent versions.
37
37
- MSI installers are used on Windows for this, so runs will take a little longer to set up vs MacOS and Linux.
38
38
39
-
You should specify **only a major and minor version** if you are okay with the most recent patch version being used:
39
+
You can specify **only a major and minor version** if you are okay with the most recent patch version being used:
40
40
41
41
```yaml
42
42
steps:
@@ -72,7 +72,7 @@ steps:
72
72
- run: python my_script.py
73
73
```
74
74
75
-
You can also use several types of ranges that are specified in [Semantic Versioning Specification](https://github.com/npm/node-semver#ranges), for instance:
75
+
You can also use several types of ranges that are specified in [semver](https://github.com/npm/node-semver#ranges), for instance:
76
76
77
77
- **[hyphen ranges](https://github.com/npm/node-semver#hyphen-ranges-xyz---abc)** to download and set up the latest available version of Python (includes both pre-release and stable versions):
78
78
@@ -95,14 +95,13 @@ steps:
95
95
python-version: '3.x'
96
96
- run: python my_script.py
97
97
```
98
-
Please refer to the [Advanced range syntax section](https://github.com/npm/node-semver#advanced-range-syntax) of the [Semantic Versioning Specification](https://github.com/npm/node-semver) to check other available range syntaxes.
98
+
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.
99
99
100
100
## Specifying a PyPy version
101
101
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
102
102
The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy version will be used in this case.
103
103
104
104
```
105
-
pypy3.7 or pypy-3.7 # the latest available version of PyPy that supports Python 3.7
106
105
pypy3.8 or pypy-3.8 # the latest available version of PyPy that supports Python 3.8
107
106
pypy2.7 or pypy-2.7 # the latest available version of PyPy that supports Python 2.7
108
107
pypy3.7-v7.3.3 or pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
@@ -122,15 +121,14 @@ jobs:
122
121
python-version:
123
122
- 'pypy3.7' # the latest available version of PyPy that supports Python 3.7
124
123
- 'pypy3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
125
-
- 'pypy3.8' # the latest available version of PyPy that supports Python 3.8
126
124
steps:
127
125
- uses: actions/checkout@v3
128
126
- uses: actions/setup-python@v4
129
127
with:
130
128
python-version: ${{ matrix.python-version }}
131
129
- run: python my_script.py
132
130
```
133
-
More details on PyPy syntax and examples of using preview / nightly versions of PyPy can be found in the [Available versions of PyPy](#pypy) section.
131
+
More details on PyPy syntax can be found in the [Available versions of PyPy](#pypy) section.
**Using a list of wildcard patterns to cache dependencies**
271
269
```yaml
@@ -287,7 +285,7 @@ steps:
287
285
288
286
### `python-version`
289
287
290
-
Using **python-version** output it's possible to get the installed by action python's version. This output is useful when the input `python-version` given as a range (e.g. 3.8.0 - 3.10.0 ), but down in a workflow you need to operate with exact installed version (e.g. 3.10.1).
288
+
Using **python-version** output it's possible to get the installed by action Pytho/PyPy version. This output is useful when the input `python-version` given as a range (e.g. 3.8.0 - 3.10.0 ), but down in a workflow you need to operate with the exact installed version (e.g. 3.10.1).
291
289
292
290
```yaml
293
291
jobs:
@@ -304,7 +302,7 @@ jobs:
304
302
305
303
### `python-path`
306
304
307
-
**python-path** output is available with the absolute path of the python interpreter executable if you need it:
305
+
**python-path** output is available with the absolute path of the Python/PyPy interpreter executable if you need it:
308
306
309
307
```yaml
310
308
jobs:
@@ -318,12 +316,29 @@ jobs:
318
316
python-version: "3.10"
319
317
- run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version
320
318
```
319
+
### `cache-hit`
320
+
321
+
**cache-hit** output is available with a boolean value that indicates whether a cache hit occured on the primary key:
322
+
323
+
```
324
+
jobs:
325
+
build:
326
+
runs-on: ubuntu-latest
327
+
steps:
328
+
- uses: actions/checkout@v3
329
+
- uses: actions/setup-python@v4
330
+
id: cp310
331
+
with:
332
+
python-version: "3.8.0"
333
+
cache: "poetry"
334
+
- run: echo '${{ steps.cp310.outputs.cache-hit }}' # true if cache-hit occured on the primary key
335
+
```
321
336
322
337
## Evironment variables
323
338
324
339
These environment variables become available after setup-python action execution:
325
340
326
-
| Env.Variable | Description |
341
+
| **Env.variable** | **Description** |
327
342
| ----------- | ----------- |
328
343
| pythonLocation |Contains the absolute path to the folder where the requested version of Python or PyPy is installed|
@@ -333,10 +348,10 @@ These environment variables become available after setup-python action execution
333
348
## Using `update-environment` flag
334
349
335
350
The `update-environment` flag defaults to `true`.
336
-
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for `python` to just work out of the box.
351
+
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for Python/PyPy to just work out of the box.
337
352
338
353
If `update-environment` is set to `false`, the action will not add/update environment variables.
339
-
This can prove useful if you want the only side-effect to be to ensure python is installed and rely on the `python-path` output to run python.
354
+
This can prove useful if you want the only side-effect to be to ensure Python/PyPy is installed and rely on the `python-path` output to run executable.
340
355
Such a requirement on side-effect could be because you don't want your composite action messing with your user's workflows.
341
356
342
357
```yaml
@@ -382,7 +397,7 @@ Such a requirement on side-effect could be because you don't want your composite
382
397
383
398
# Hosted tool cache
384
399
385
-
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 this tool cache and there is where you will find Python and PyPy installed. `setup-python` works by taking a specific version of Python or PyPy in this tool cache and adding it to PATH.
400
+
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.
0 commit comments