Compute pacboy packages from requirements.txt

This commit is contained in:
Patrick Lehmann
2022-11-05 23:57:24 +01:00
parent 301584a670
commit 5cc87cf754

View File

@@ -37,11 +37,7 @@ on:
pacboy:
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
required: false
default: >-
python-pip:p
python-wheel:p
python-coverage:p
python-lxml:p
default: ""
type: string
mingw_requirements:
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
@@ -83,13 +79,67 @@ jobs:
- name: ⏬ Checkout repository
uses: actions/checkout@v3
- name: Install dependencies for compute step
if: matrix.system == 'msys2'
run: pip install pyTooling
- name: Compute pacman/pacboy packages
id: pacboy
if: matrix.system == 'msys2'
shell: python
run: |
from os import getenv
from pathlib import Path
from re import compile
from pyTooling.Packageing import loadRequirementsFile
requirementsFile = Path("${{ inputs.requirements }}")
dependencies = loadRequirementsFile(requirementsFile)
filter = {
"pip": "python-pip:p",
"wheel": "python-wheel:p",
"coverage": "python-coverage:p",
"lxml": "python-lxml:p",
"ruamel-yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p",
"numpy": "python-numpy:p",
}
regExp = compile(r"([\w_\-\.]+)(\s*(?:[<>=]+)\s*)(\d+(?:.\d+)*)")
packages = []
print(f"Processing requirements ({len(dependencies)}):")
for dependency in dependencies:
match = regExp.match(dependency)
if not match:
print(f" Wrong format: {dependency}")
continue
try:
package = match[0]
rewrite = filter[package]
print(f" Found rewrite rule for '{package}': {rewrite}")
packages.append(rewrite)
except KeyError:
continue
# Write jobs to special file
github_output = Path(getenv("GITHUB_OUTPUT"))
print(f"GITHUB_OUTPUT: {github_output}")
with github_output.open("a+") as f:
f.write(f"pacboy_packages={' '.join(packages)}\n")
- name: '🟦 Setup MSYS2'
if: matrix.system == 'msys2'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
pacboy: ${{ inputs.pacboy }}
pacboy: >-
${{ steps.pacboy.outputs.pacboy_packages }}
${{ inputs.pacboy }}
- name: 🐍 Setup Python ${{ matrix.python }}
if: matrix.system != 'msys2'