Skip to content

Python Environment Setup

Actions
Installs Python, Poetry, dependencies and pre-commit
v1.0.1
Latest
Star (1)

Tags

 (1)

License Release

Python Environment Setup Action

A Github action for installing and configuring

This action caches heavily, to speed up your workflow. It is a composite action which can be viewed at action.yml.

Usage

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'

The python-version input is required, however the action automatically chooses the latest Poetry version.

Poetry will be added to Path, and the venv will be created in the project directory. Scripts can be run using poetry run <script>. For example, to run pytest, use poetry run pytest.

To source the venv, add this to your workflow:

- name: Source the venv
  run: source $VENV

Also see #windows if you are using Windows runners.

Cache

This action caches the Poetry installation, it's venv, and pre-commit hooks.

To disable the cache entirely, the use-cache input can be set to false.

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'
    use-cache: false

pre-commit

To use pre-commit, it must be added to Poetry's dev-dependencies.

poetry add --group dev pre-commit

To skip installing pre-commit, the skip-precommit input can be set to true.

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'
    skip-precommit: true

Windows

You must set the default shell to be bash, by adding the following in your workflow.

defaults:
  run:
    shell: bash

On Windows runners, only pre-commit hooks are cached, since caching the Poetry installation and venv is problematic.

Credits

The snok/install-poetry action is used to install Poetry.

Python Environment Setup is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Installs Python, Poetry, dependencies and pre-commit
v1.0.1
Latest

Tags

 (1)

Python Environment Setup is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.