From 8746627039798b6f194ffdd9f726db39642a302d Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Fri, 3 Dec 2021 10:02:26 -0800 Subject: [PATCH] python/update-python-libraries: enable updates when file contains many pnames --- .../update-python-libraries.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py index d3642592ae43..b27204c16245 100755 --- a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py +++ b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py @@ -309,8 +309,8 @@ def _update_package(path, target): with open(path, 'r') as f: text = f.read() - # Determine pname. - pname = _get_unique_value('pname', text) + # Determine pname. Many files have more than one pname + pnames = _get_values('pname', text) # Determine version. version = _get_unique_value('version', text) @@ -320,7 +320,18 @@ def _update_package(path, target): extension = _determine_extension(text, fetcher) - new_version, new_sha256, prefix = FETCHERS[fetcher](pname, extension, version, target) + # Attempt a fetch using each pname, e.g. backports-zoneinfo vs backports.zoneinfo + successful_fetch = False + for pname in pnames: + try: + new_version, new_sha256, prefix = FETCHERS[fetcher](pname, extension, version, target) + successful_fetch = True + break + except ValueError: + continue + + if not successful_fetch: + raise ValueError(f"Unable to find correct package using these pnames: {pnames}") if new_version == version: logging.info("Path {}: no update available for {}.".format(path, pname))