Skip to content

About

Set up your GitHub Actions workflow with a specific version of python

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

setup-python V2

GitHub Actions status

This action sets up a Python environment for use in actions by:

  • optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
  • downloading, installing and adding to PATH an available version of Python from GitHub Releases (actions/python-versions) if a specific version is not available in the tools cache.
  • failing if a specific version of Python is not preinstalled or available for download.
  • registering problem matchers for error output.

What's new

  • Ability to download, install and set up Python packages from actions/python-versions that do not come preinstalled on runners.
    • Allows for pinning to a specific patch version of Python without the worry of it ever being removed or changed.
  • Automatic setup and download of Python packages if using a self-hosted runner.
  • Support for pre-release versions of Python.

Usage

See action.yml

Basic:

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
  with:
    python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
    architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- run: python my_script.py

Matrix Testing:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ '2.x', '3.x', 'pypy2', 'pypy3' ]
    name: Python ${{ matrix.python-version }} sample
    steps:
      - uses: actions/checkout@v2
      - name: Setup python