diff --git a/odl/util/utility.py b/odl/util/utility.py index 828ee0ed5d1..b7da61ffb7b 100644 --- a/odl/util/utility.py +++ b/odl/util/utility.py @@ -1505,7 +1505,7 @@ def pkg_supports(feature, pkg_version, pkg_feat_dict): >>> pkg_supports('feat5', '1.0', feat_dict) False """ - from pkg_resources import parse_requirements + from packaging.requirements import Requirement feature = str(feature) pkg_version = str(pkg_version) @@ -1521,16 +1521,11 @@ def pkg_supports(feature, pkg_version, pkg_feat_dict): ver_specs = ['pkg' + supp_ver for supp_ver in supp_versions] # Each parse_requirements list contains only one entry since we specify # only one package - ver_reqs = [list(parse_requirements(ver_spec))[0] - for ver_spec in ver_specs] + ver_reqs = [Requirement(ver_spec) for ver_spec in ver_specs] - # If one of the requirements in the list is met, return True - for req in ver_reqs: - if req.specifier.contains(pkg_version, prereleases=True): - return True - - # No match - return False + # If one of the requirements in the list is met, return True, else False + return any(req.specifier.contains(pkg_version, prereleases=True) + for req in ver_reqs) class NumpyRandomSeed(object):