From b10c2f4003f14a57b196a2a450d2fef4e4932515 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 16 Dec 2022 11:53:54 -0800 Subject: [PATCH] Fix bindep on Arch with packaging>=22.0 packaging 22.0 removed the LegacyVersion object which was the fallback when an invalid version was found. Now when an invalid version is found packaging raises and exception. This appears to be a problem for rolling release distros like Arch and Manjaro as they don't have versions. To fix this we catch the exception and set our object value to None. This will cause us to error later should we actually need the version for some reason. When we don't need it as with Arch/Manjaro we continue along just fine. Change-Id: Ic9ec6a3a492a7f95cf9d2865f88d79c6c5de796c --- bindep/depends.py | 10 ++++++++-- requirements.txt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bindep/depends.py b/bindep/depends.py index 3853251..5026a0b 100644 --- a/bindep/depends.py +++ b/bindep/depends.py @@ -22,7 +22,7 @@ from parsley import makeGrammar import platform import subprocess import sys -from packaging.version import parse as as_ver +from packaging.version import InvalidVersion, parse as as_ver import distro @@ -327,7 +327,13 @@ class Depends(object): # NOTE(toabctl): distro can be more than one string (i.e. "SUSE LINUX") codename = distro.codename().lower() release = distro.version().lower() - release_version = as_ver(release) + try: + release_version = as_ver(release) + except InvalidVersion: + # Rolling releases like Arch and Manjaro have no + # version. Ignore it and fail later if we actually need + # to check versions + release_version = None # NOTE(toabctl): space is a delimiter for bindep, so remove the spaces distro_id = "".join(distro_id.split()).lower() atoms = set([distro_id]) diff --git a/requirements.txt b/requirements.txt index 7a3dc49..2431d42 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ distro<1.7.0 ; python_version < '3.6' distro>=1.7.0 ; python_version >= '3.6' pbr>=2.0.0 # Apache-2.0 Parsley -packaging<22.0 ; python_version >= '3.6' +packaging ; python_version >= '3.6' packaging<21.0 ; python_version < '3.6'