Install Python packages using pipx with cache support on GitHub Actions.
Use this project to install Python packages with pipx, especially for tools written in Python that should be installed in isolated environments. After installation, it automatically saves the installed packages to a cache, speeding up installations for subsequent workflow runs.
This project includes two components: a GitHub Action that can be used directly in workflows, and a JavaScript library that provides functions for use in a JavaScript Action.
Use the following snippet to include the action in a GitHub workflow:
- name: Install Packages
uses: threeal/pipx-install-action@v2.0.0
with:
packages: a-package another-package
Name | Type | Description |
---|---|---|
packages |
Multiple strings | Names of the Python packages to be installed. |
This example demonstrates how to use the Pipx Install Action to install Ruff in a GitHub Actions workflow:
name: Python CI
on:
push:
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Install Ruff
uses: threeal/pipx-install-action@v2.0.0
with:
packages: ruff
# Add more steps as needed for the workflow
Install the JavaScript library using a package manager:
npm install pipx-install-action
The library provides several functions for installing and caching Python packages within GitHub Actions. Refer to the documentation for more information about the functions available in this action and their usage.
This example demonstrates how to use this library to install and cache Ruff in a JavaScript action:
import {
installPipxPackage,
restorePipxPackageCache,
savePipxPackageCache,
} from "pipx-install-action";
const restored = await restorePipxPackageCache("ruff");
if (!restored) {
await installPipxPackage("ruff");
await savePipxPackageCache("ruff");
}
The code above first attempts to restore the Ruff package cache. If the cache is unavailable, it installs the package and saves it to the cache for future workflow runs.
This project is licensed under the terms of the MIT License.
Copyright © 2024 Alfi Maulana