Skip to content

Commit

Permalink
Parse package versions so upgrades can be forced (Significant-Gravita…
Browse files Browse the repository at this point in the history
…s#4149)

* parse package versions so upgrades can be forced

* better version from @collijk
  • Loading branch information
k-boikov authored May 12, 2023
1 parent 21a202b commit 12e806d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/check_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ def main():
line.strip().split("#")[0].strip() for line in f.readlines()
]

installed_packages = [package.key for package in pkg_resources.working_set]
installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}

missing_packages = []
for package in required_packages:
if not package: # Skip empty lines
for required_package in required_packages:
if not required_package: # Skip empty lines
continue
package_name = re.split("[<>=@ ]+", package.strip())[0]
if package_name.lower() not in installed_packages:
missing_packages.append(package_name)
pkg = pkg_resources.Requirement.parse(required_package)
if (
pkg.key not in installed_packages
or pkg_resources.parse_version(installed_packages[pkg.key])
not in pkg.specifier
):
missing_packages.append(str(pkg))

if missing_packages:
print("Missing packages:")
Expand Down

0 comments on commit 12e806d

Please sign in to comment.