From 24aa375ab6718966e35f65e9e3d2d0901c38f13d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 15 Nov 2022 20:13:40 +0100 Subject: [PATCH] Improved Python dependency scanner for MSYS2. --- .github/workflows/UnitTesting.yml | 43 +++++++++++++++++++------------ doc/requirements.txt | 2 +- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/UnitTesting.yml b/.github/workflows/UnitTesting.yml index 05361ea..3bb187b 100644 --- a/.github/workflows/UnitTesting.yml +++ b/.github/workflows/UnitTesting.yml @@ -110,11 +110,7 @@ jobs: else: dependencies = [req.strip() for req in requirements.split(" ")] - print(f"Dependencies ({len(dependencies)}):") - for dependency in dependencies: - print(f" {dependency}") - - filter = { + packages = { "pip": "python-pip:p", "wheel": "python-wheel:p", "coverage": "python-coverage:p", @@ -123,30 +119,43 @@ jobs: "numpy": "python-numpy:p", "igraph": "igraph:p", } + subPackages = { + "pyTooling": { + "yaml": "python-ruamel-yaml:p python-ruamel.yaml.clib:p", + } + } - regExp = compile(r"([\w_\-\.]+)(\s*(?:[<>=]+)\s*)(\d+(?:.\d+)*)") + regExp = compile(r"(?P[\w_\-\.]+)(?:\[(?P(?:\w+)(?:,\w+)*)\])?(?:\s*(?P[<>=]+)\s*)(?P\d+(?:\.\d+)*)(?:-(?P\w+))?") - packages = set(("python-pip:p", "python-wheel:p")) - print(f"Processing requirements ({len(dependencies)}):") + pacboyPackages = set(("python-pip:p", "python-wheel:p")) + print(f"Processing dependencies ({len(dependencies)}):") for dependency in dependencies: + print(f" {dependency}") + match = regExp.match(dependency) if not match: - print(f" Wrong format: {dependency}") + print(f" Wrong format: {dependency}") + print(f"::error title=Identifying Pacboy Packages::Unrecognized dependency format '{dependency}'") continue - package = match[1] - try: - rewrite = filter[package] - print(f" Found rewrite rule for '{package}': {rewrite}") - packages.add(rewrite) - except KeyError: - continue + package = match["PackageName"] + if package in packages: + rewrite = packages[package] + print(f" Found rewrite rule for '{package}': {rewrite}") + pacboyPackages.add(rewrite) + + if match["SubPackages"] and package in subPackages: + for subPackage in match["SubPackages"].split(","): + if subPackage in subPackages[package]: + rewrite = subPackages[package][subPackage] + print(f" Found rewrite rule for '{package}[..., {subPackage}, ...]': {rewrite}") + pacboyPackages.add(rewrite) # 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") + f.write(f"pacboy_packages={' '.join(pacboyPackages)}\n") - name: '🟦 Setup MSYS2' if: matrix.system == 'msys2' diff --git a/doc/requirements.txt b/doc/requirements.txt index 30d1e68..5f2ddc2 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,6 +1,6 @@ -r ../requirements.txt -pyTooling>=2.5.0 +pyTooling>=2.6.0 # Enforce latest version on ReadTheDocs sphinx>=5.3.0