mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
Compute pacboy packages from requirements.txt
This commit is contained in:
62
.github/workflows/UnitTesting.yml
vendored
62
.github/workflows/UnitTesting.yml
vendored
@@ -37,11 +37,7 @@ on:
|
|||||||
pacboy:
|
pacboy:
|
||||||
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
|
description: 'MSYS2 dependencies to be installed through pacboy (pacman).'
|
||||||
required: false
|
required: false
|
||||||
default: >-
|
default: ""
|
||||||
python-pip:p
|
|
||||||
python-wheel:p
|
|
||||||
python-coverage:p
|
|
||||||
python-lxml:p
|
|
||||||
type: string
|
type: string
|
||||||
mingw_requirements:
|
mingw_requirements:
|
||||||
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
|
description: 'Override Python dependencies to be installed through pip on MSYS2 (MINGW64) only.'
|
||||||
@@ -83,13 +79,67 @@ jobs:
|
|||||||
- name: ⏬ Checkout repository
|
- name: ⏬ Checkout repository
|
||||||
uses: actions/checkout@v3
|
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'
|
- name: '🟦 Setup MSYS2'
|
||||||
if: matrix.system == 'msys2'
|
if: matrix.system == 'msys2'
|
||||||
uses: msys2/setup-msys2@v2
|
uses: msys2/setup-msys2@v2
|
||||||
with:
|
with:
|
||||||
msystem: MINGW64
|
msystem: MINGW64
|
||||||
update: true
|
update: true
|
||||||
pacboy: ${{ inputs.pacboy }}
|
pacboy: >-
|
||||||
|
${{ steps.pacboy.outputs.pacboy_packages }}
|
||||||
|
${{ inputs.pacboy }}
|
||||||
|
|
||||||
- name: 🐍 Setup Python ${{ matrix.python }}
|
- name: 🐍 Setup Python ${{ matrix.python }}
|
||||||
if: matrix.system != 'msys2'
|
if: matrix.system != 'msys2'
|
||||||
|
|||||||
Reference in New Issue
Block a user