- Saved searches
- Use saved searches to filter your results more quickly
- GitHub Action
- Setup Python
- Setup Python
- Saved searches
- Use saved searches to filter your results more quickly
- GitHub Action
- Latest Python Versions
- Latest Python Versions
- Saved searches
- Use saved searches to filter your results more quickly
- License
- actions/python-versions
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Saved searches
Use saved searches to filter your results more quickly
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.
GitHub Action
Setup Python
Setup Python
Set up a specific version of Python and add the command-line tools to the PATH
Installation
Copy and paste the following snippet into your .yml file.
- name: Setup Python uses: actions/setup-python@v4.7.0
This action provides the following functionality for GitHub Actions users:
- Installing a version of Python or PyPy and (by default) adding it to the PATH
- Optionally caching dependencies for pip, pipenv and poetry
- Registering problem matchers for error output
steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.10' - run: python my_script.py
steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: 'pypy3.9' - run: python my_script.py
The python-version input is optional. If not supplied, the action will try to resolve the version from the default .python-version file. If the .python-version file doesn’t exist Python or PyPy version from the PATH will be used. The default version of Python or PyPy in PATH varies between runners and can be changed unexpectedly so we recommend always setting Python version explicitly using the python-version or python-version-file inputs.
The action will first check the local tool cache for a semver 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 and for PyPy from the official PyPy’s dist.
For information regarding locally cached versions of Python or PyPy on GitHub hosted runners, check out GitHub Actions Runner Images.
The python-version input supports the Semantic Versioning Specification 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 of the Advanced usage guide.
Using architecture input it is possible to specify the required Python or PyPy interpreter architecture: x86 or x64 . If the input is not specified the architecture defaults to x64 .
Caching packages dependencies
The action has built-in functionality for caching and restoring dependencies. It uses toolkit/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 or pyproject.toml 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.
- For pip , the action will cache the global cache directory
- For pipenv , the action will cache virtualenv directory
- For poetry , the action will cache virtualenv directories — one for each poetry project found
Caching pip dependencies:
steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' # caching pip dependencies - run: pip install -r requirements.txt
Note: Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available which can lead to an increase in total build time.
The requirements file format allows for specifying dependency versions using logical operators (for example chardet>=3.0.4) or specifying dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary.
See examples of using cache and cache-dependency-path for pipenv and poetry in the section: Caching packages of the Advanced usage guide.
The scripts and documentation in this project are released under the MIT License.
Contributions are welcome! See our Contributor’s Guide.
GitHub has verified that this action was created by actions.
Saved searches
Use saved searches to filter your results more quickly
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.
GitHub Action
Latest Python Versions
Latest Python Versions
Installation
- name: Latest Python Versions uses: snok/latest-python-versions@v1.1.2
This action will fetch up-to-date data on the latest Python versions available on Github Actions. If you’re already running tests on multiple Python versions, this action will allow you to replace your static matrix definitions with dynamic ones. With a dynamic version matrix definition, you will for example always be on the latest pre-release of the next upcoming Python release. The Python versions are fetched from here — the official Github action version manifest.
- uses: snok/latest-python-versions@v1 id: get-python-versions with: min-version: 3.7 max-version: 3.10 # not required - defaults to latest include-prereleases: true # not required - defaults to false
name: Test on: pull_request jobs: linting: . # Define the job to run before your matrix job get-python-versions: runs-on: ubuntu-latest outputs: python-matrix: $> steps: - uses: snok/latest-python-versions@v1 id: get-python-versions-action with: min-version: 3.8 include-prereleases: true # Then use the output from the previous job in the matrix definition test: needs: [linting, get-python-versions] runs-on: ubuntu-latest strategy: matrix: python-version: $> steps: - uses: actions/setup-python@v4 with: python-version: $>
Saved searches
Use saved searches to filter your results more quickly
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.
Python builds for Actions Runner Images
License
actions/python-versions
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
This repository contains the code and scripts that we use to build Python packages used in runner-images and accessible through the setup-python Action. File versions-manifest.json contains the list of available and released versions.
Caution: this is prepared for and only permitted for use by actions runner-images and setup-python action.
Some versions are pre-installed on runner-images images. More versions are available to install on-the-fly through the setup-python action.
Building installation packages
Ubuntu: The official Python sources are downloaded from python.org, built using the make tool, and archived along with the installation script for further distribution and installation. We build each Python version against all versions of Ubuntu that are available at the time the Python version is released.
- For Python < 3.11, the official Python sources are downloaded from python.org, built using the make tool, and archived along with the installation script for further distribution and installation. For backward compatibility, we build each Python version against the oldest version of macOS that is available at the time the Python version is released.
- For Python >= 3.11, the official macOS universal2 Python binaries are simply downloaded from python.org and archived along with the installation script for further distribution and installation.
Windows: The official Python executables are simply downloaded from python.org and archived along with the installation script for further distribution and installation.
We aim to make new versions of Python available as soon as they are released. Both stable and prerelease versions are considered for building and releasing. Please open an issue in actions/setup-python if a version you’re looking for isn’t available.
When a new version of an operating system is released and made available for use with GitHub hosted runners, we will provide the latest existing patch versions of Python for all major versions that have not reached end-of-life. Any subsequent Python versions will be made available for the new OS as well.
Contributions are welcome! See Contributor’s Guide for more details about contribution process and code structure