diff options
Diffstat (limited to 'pkgs/servers')
-rwxr-xr-x | pkgs/servers/home-assistant/parse-requirements.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/pkgs/servers/home-assistant/parse-requirements.py b/pkgs/servers/home-assistant/parse-requirements.py index 43e21dcfd9229..ef65e795ed34c 100755 --- a/pkgs/servers/home-assistant/parse-requirements.py +++ b/pkgs/servers/home-assistant/parse-requirements.py @@ -29,6 +29,7 @@ from typing import Any, Dict, List, Optional, Set from urllib.request import urlopen from packaging import version as Version +from packaging.version import InvalidVersion from rich.console import Console from rich.table import Table @@ -197,6 +198,8 @@ def main() -> None: # Therefore, if there's a "#" in the line, only take the part after it req = req[req.find("#") + 1 :] name, required_version = req.split("==", maxsplit=1) + # Strip conditions off version constraints e.g. "1.0; python<3.11" + required_version = required_version.split(";").pop(0) # Split package name and extra requires extras = [] if name.endswith("]"): @@ -206,11 +209,20 @@ def main() -> None: if attr_path: if our_version := get_pkg_version(attr_path, packages): attr_name = attr_path.split(".")[-1] - if Version.parse(our_version) < Version.parse(required_version): - outdated[attr_name] = { - 'wanted': required_version, - 'current': our_version - } + attr_outdated = False + try: + Version.parse(our_version) + except InvalidVersion: + print(f"Attribute {attr_name} has invalid version specifier {our_version}", file=sys.stderr) + attr_outdated = True + else: + attr_outdated = Version.parse(our_version) < Version.parse(required_version) + finally: + if attr_outdated: + outdated[attr_name] = { + 'wanted': required_version, + 'current': our_version + } if attr_path is not None: # Add attribute path without "python3Packages." prefix pname = attr_path[len(PKG_SET + "."):] |