From: Jeremy Stanley Date: Sat, 9 Oct 2021 16:57:22 +0000 (+0000) Subject: Strip specifiers in dependency version strings X-Git-Tag: 0.5.0~13 X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=commitdiff_plain;h=6f1c33f05d3334c44d2afd4a8b062f18111e1846;hp=e7543a4ea7d8427f6590102f3f3d81a7548e808e Strip specifiers in dependency version strings When comparing installed module names with the package dependencies, chop off the version specifiers included with the requirements strings in order to ease matching them. --- diff --git a/mudpy/version.py b/mudpy/version.py index d99617e..aa1e3eb 100644 --- a/mudpy/version.py +++ b/mudpy/version.py @@ -1,6 +1,6 @@ """Version and diagnostic information for the mudpy engine.""" -# Copyright (c) 2018-2020 mudpy authors. Permission to use, copy, +# Copyright (c) 2018-2021 mudpy authors. Permission to use, copy, # modify, and distribute this software is granted under terms # provided in the LICENSE file distributed with this software. @@ -113,8 +113,16 @@ class Versions: def _normalize_project(project_name): - """Convenience function to normalize Python project names.""" + """Strip and normalize Python project names.""" + + # Use lower-case names for ease of comparison if use_importlib: - return project_name.lower() + project_name = project_name.lower() else: - return pkg_resources.safe_name(project_name).lower() + project_name = pkg_resources.safe_name(project_name).lower() + + # Remove any version specifiers included with requirements strings + for operator in ' <>=!': + project_name = project_name.split(operator)[0] + + return project_name