Improved Python dependency scanner for MSYS2.

This commit is contained in:
Patrick Lehmann
2022-11-15 20:13:40 +01:00
parent d15059eccb
commit 24aa375ab6
2 changed files with 27 additions and 18 deletions

View File

@@ -110,11 +110,7 @@ jobs:
else: else:
dependencies = [req.strip() for req in requirements.split(" ")] dependencies = [req.strip() for req in requirements.split(" ")]
print(f"Dependencies ({len(dependencies)}):") packages = {
for dependency in dependencies:
print(f" {dependency}")
filter = {
"pip": "python-pip:p", "pip": "python-pip:p",
"wheel": "python-wheel:p", "wheel": "python-wheel:p",
"coverage": "python-coverage:p", "coverage": "python-coverage:p",
@@ -123,30 +119,43 @@ jobs:
"numpy": "python-numpy:p", "numpy": "python-numpy:p",
"igraph": "igraph: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<PackageName>[\w_\-\.]+)(?:\[(?P<SubPackages>(?:\w+)(?:,\w+)*)\])?(?:\s*(?P<Comperator>[<>=]+)\s*)(?P<Version>\d+(?:\.\d+)*)(?:-(?P<VersionExtension>\w+))?")
packages = set(("python-pip:p", "python-wheel:p")) pacboyPackages = set(("python-pip:p", "python-wheel:p"))
print(f"Processing requirements ({len(dependencies)}):") print(f"Processing dependencies ({len(dependencies)}):")
for dependency in dependencies: for dependency in dependencies:
print(f" {dependency}")
match = regExp.match(dependency) match = regExp.match(dependency)
if not match: 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 continue
package = match[1] package = match["PackageName"]
try: if package in packages:
rewrite = filter[package] rewrite = packages[package]
print(f" Found rewrite rule for '{package}': {rewrite}") print(f" Found rewrite rule for '{package}': {rewrite}")
packages.add(rewrite) pacboyPackages.add(rewrite)
except KeyError:
continue 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 # Write jobs to special file
github_output = Path(getenv("GITHUB_OUTPUT")) github_output = Path(getenv("GITHUB_OUTPUT"))
print(f"GITHUB_OUTPUT: {github_output}") print(f"GITHUB_OUTPUT: {github_output}")
with github_output.open("a+") as f: 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' - name: '🟦 Setup MSYS2'
if: matrix.system == 'msys2' if: matrix.system == 'msys2'

View File

@@ -1,6 +1,6 @@
-r ../requirements.txt -r ../requirements.txt
pyTooling>=2.5.0 pyTooling>=2.6.0
# Enforce latest version on ReadTheDocs # Enforce latest version on ReadTheDocs
sphinx>=5.3.0 sphinx>=5.3.0