From 17df30d81847e24edfcfbd74aa65b05b4c7f2676 Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley <31761158+garethsb@users.noreply.github.com> Date: Fri, 23 Feb 2024 13:52:27 +0000 Subject: [PATCH] Better parsing of requirements.txt lines (#846) --- nmostesting/NMOSTesting.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nmostesting/NMOSTesting.py b/nmostesting/NMOSTesting.py index e4860827..b7b30708 100644 --- a/nmostesting/NMOSTesting.py +++ b/nmostesting/NMOSTesting.py @@ -966,6 +966,14 @@ def run_noninteractive_tests(args): return exit_code +def get_package_name(requirement): + pattern = r'^([^\s>=<]+)' + match = re.match(pattern, requirement) + if match: + return match.group(1) + return None + + def check_internal_requirements(): corrections = {"gitpython": "git", "pyopenssl": "OpenSSL", @@ -976,7 +984,7 @@ def check_internal_requirements(): installed_pkgs = [pkg[1] for pkg in pkgutil.iter_modules()] with open("requirements.txt") as requirements_file: for requirement in requirements_file.readlines(): - requirement_name = requirement.strip().split(">")[0] + requirement_name = get_package_name(requirement) if requirement_name in corrections: corrected_req = corrections[requirement_name] else: