3
0
Fork 0
mirror of https://gitea.com/actions/setup-python.git synced 2024-11-23 02:29:35 +01:00

Fix review points

This commit is contained in:
IvanZosimov 2022-07-26 14:47:59 +02:00
parent b152b04c28
commit 81cda82fb0
3 changed files with 20 additions and 20 deletions

View file

@ -6,7 +6,9 @@
This action provides the following functionalities for GitHub Actions users: This action provides the following functionalities for GitHub Actions users:
- Optionally downloading and installing the requested version of Python/PyPy and adding it to the PATH - Optionally installing and adding to PATH a version of Python that is already installed in the runner's tool cache.
- 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.
- Failing if a specific version of Python is not preinstalled or available for download.
- Optionally caching dependencies for pip, pipenv and poetry - Optionally caching dependencies for pip, pipenv and poetry
- Registering problem matchers for error output - Registering problem matchers for error output
@ -18,7 +20,7 @@ See [action.yml](action.yml)
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 # <- v4 is a major release tag of the action: https://github.com/actions/setup-python/tags - uses: actions/setup-python@v4
with: with:
python-version: '3.10' python-version: '3.10'
- run: python my_script.py - run: python my_script.py
@ -49,7 +51,7 @@ Using `architecture` input it is possible to specify the required Python/PyPy in
## Caching packages dependencies ## Caching packages dependencies
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default. The action has built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default.
The action defaults to searching for a dependency file (`requirements.txt` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Input `cache-dependency-path` is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used. The action defaults to searching for a dependency file (`requirements.txt` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Input `cache-dependency-path` is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used.

View file

@ -1,33 +1,33 @@
--- ---
name: 'Setup Python' name: "Setup Python"
description: 'Set up a specific version of Python and add the command-line tools to the PATH.' description: "Set up a specific version of Python and add the command-line tools to the PATH."
author: 'GitHub' author: "GitHub"
inputs: inputs:
python-version: python-version:
description: "Version range or exact version of Python/PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset." description: "Version range or exact version of Python/PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset."
python-version-file: python-version-file:
description: "File containing the Python version to use. Example: .python-version" description: "File containing the Python version to use. Example: .python-version"
cache: cache:
description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry.' description: "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry."
required: false required: false
architecture: architecture:
description: "The target architecture (x86, x64) of the Python/PyPy interpreter." description: "The target architecture (x86, x64) of the Python/PyPy interpreter."
check-latest: check-latest:
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec.' description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
default: false default: false
token: token:
description: "Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user." description: "Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user."
default: ${{ github.token }} default: ${{ github.token }}
cache-dependency-path: cache-dependency-path:
description: 'Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies.' description: "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies."
update-environment: update-environment:
description: 'Set this option if you want the action to update environment variables.' description: "Set this option if you want the action to update environment variables."
default: true default: true
outputs: outputs:
python-version: python-version:
description: "The installed Python/PyPy version. Useful when given a version range as input." description: "The installed Python/PyPy version. Useful when given a version range as input."
cache-hit: cache-hit:
description: 'A boolean value to indicate a cache entry was found' description: "A boolean value to indicate a cache entry was found"
python-path: python-path:
description: "The absolute path to the Python/PyPy executable." description: "The absolute path to the Python/PyPy executable."
runs: runs:

View file

@ -1,4 +1,4 @@
# Table of contents # Contents
- [Using python-version input](advanced-usage.md#using-python-version-file-input) - [Using python-version input](advanced-usage.md#using-python-version-file-input)
- [Specifying a Python version](advanced-usage.md#specifying-a-python-version) - [Specifying a Python version](advanced-usage.md#specifying-a-python-version)
- [Specifying a PyPy version](advanced-usage.md#specifying-a-pypy-version) - [Specifying a PyPy version](advanced-usage.md#specifying-a-pypy-version)
@ -19,11 +19,9 @@
# Using python-version input # Using python-version input
The `python-version` input is used to specify the required version of Python or PyPy.
## Specifying a Python version ## Specifying a Python version
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`): 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`):
```yaml ```yaml
steps: steps:
@ -36,7 +34,7 @@ steps:
- 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. - 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.
- MSI installers are used on Windows for this, so runs will take a little longer to set up vs MacOS and Linux. - MSI installers are used on Windows for this, so runs will take a little longer to set up vs MacOS and Linux.
You can specify **only a major and minor version** if you are okay with the most recent patch version being used: You can specify ***only a major and minor version*** if you are okay with the most recent patch version being used:
```yaml ```yaml
steps: steps:
@ -50,7 +48,7 @@ steps:
- The patch version that will be preinstalled, will generally be the latest and every time there is a new patch released, the older version that is preinstalled will be replaced. - The patch version that will be preinstalled, will generally be the latest and every time there is a new patch released, the older version that is preinstalled will be replaced.
- Using the most recent patch version will result in a very quick setup since no downloads will be required since a locally installed version of Python on the runner will be used. - Using the most recent patch version will result in a very quick setup since no downloads will be required since a locally installed version of Python on the runner will be used.
You can specify the version with **prerelease tag** to download and set up an accurate pre-release version of Python: You can specify the version with ***prerelease tag*** to download and set up an accurate pre-release version of Python:
```yaml ```yaml
steps: steps:
@ -61,7 +59,7 @@ steps:
- run: python my_script.py - run: python my_script.py
``` ```
It's also possible to use **x.y-dev syntax** to download and set up the latest patch version of Python, alpha and beta releases included. (for specified major & minor versions): It's also possible to use ***x.y-dev syntax*** to download and set up the latest patch version of Python, alpha and beta releases included. (for specified major & minor versions):
```yaml ```yaml
steps: steps:
@ -74,7 +72,7 @@ steps:
You can also use several types of ranges that are specified in [semver](https://github.com/npm/node-semver#ranges), for instance: You can also use several types of ranges that are specified in [semver](https://github.com/npm/node-semver#ranges), for instance:
- **[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): - ***[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):
```yaml ```yaml
steps: steps:
@ -85,7 +83,7 @@ steps:
- run: python my_script.py - run: python my_script.py
``` ```
- **[x-ranges](https://github.com/npm/node-semver#x-ranges-12x-1x-12-)** to specify the latest stable version of Python (for specified major version): - ***[x-ranges](https://github.com/npm/node-semver#x-ranges-12x-1x-12-)*** to specify the latest stable version of Python (for specified major version):
```yaml ```yaml
steps: steps: