Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# gh-action-setup-python-with-deps
Installs Python and some extra dependencies
# Setup Python with dependencies Action

This action installs Python, upgrades `pip` and optionally installs some extra
dependencies.

Here is an example demonstrating how to use it in a workflow:

```yaml
jobs:
test:
name: Test
runs-on: ubuntu-20.04

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: frequenz-floss/gh-action-setup-python-with-deps@v0.x.x
with:
python-version: "3.11"
dependencies: "mkdocs"
- name: Run mkdocs
run: mkdocs --help
```

## Inputs

* `python-version`: The Python version to use. Required.

This is passed to the
[`actions/setup-python`](https://github.com/actions/setup-python) action.

* `dependencies`: The dependencies to install. Default: "".

This is passed to the `pip install` command as is, without any shell
escaping. If empty, no dependencies are installed.
44 changes: 44 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Setup Python with dependencies"
description: "Installs Python and some extra dependencies."
author: "Frequenz Energy-as-a-Service GmbH"

# Refer to the following link(s) for more information on inputs:
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
inputs:
python-version:
description: >
The Python version to use. This is passed to the `actions/setup-python`.
required: true
dependencies:
description: >
The dependencies to install. If empty, no dependencies are installed.

This is passed to the `pip install` command as is, without any shell escaping.
required: false
default: ""


# Refer to the following link(s) for more information on the composite run steps:
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs
runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: ${{ inputs.python-version }}
cache: pip

- name: Upgrade pip
shell: bash
run: python -m pip install --upgrade pip

- name: Install the dependencies
shell: bash
if: ${{ inputs.dependencies != '' }}
run: python -m pip install ${{ inputs.dependencies }}

- name: Print the installed dependencies (debug)
shell: bash
if: ${{ inputs.dependencies != '' }}
run: python -m pip freeze