From bf5b3736c1e4f5a3dc00d80120741865f13027ed Mon Sep 17 00:00:00 2001 From: xqt Date: Wed, 3 Jan 2024 13:51:51 +0100 Subject: [PATCH] [fix] do not check for installed 'importlib_metadata' and 'packaging' Both meodules are imported in backports and needed for the check_modules funktion. Missing modules are already printed during import of pywikibot. Change-Id: I0c46b5be772812a169de25d329ffb37ee628bab2 --- pywikibot/scripts/wrapper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py index 3b24e25f32..730b2016bc 100755 --- a/pywikibot/scripts/wrapper.py +++ b/pywikibot/scripts/wrapper.py @@ -38,7 +38,7 @@ renamed to wrapper.py """ # -# (C) Pywikibot team, 2012-2023 +# (C) Pywikibot team, 2012-2024 # # Distributed under the terms of the MIT license. # @@ -241,6 +241,14 @@ def check_modules(script: str | None = None) -> bool: from setup import dependencies for dependency in dependencies: + if dependency.startswith(('importlib_metadata', 'packaging')): + # Ignore these dependencies because ImportError is raised in an + # early state when they are imported in backports. They are already + # used at this point. This is a workaound for toolforge where some + # modules are not installed as a site-package. + # TODO: Check imports from external source + continue + requirement = Requirement(dependency) if requirement.marker is None or requirement.marker.evaluate(): try: @@ -304,7 +312,7 @@ def check_modules(script: str | None = None) -> bool: # we need to re-start the entire process. Ask the user to do so. print('Now, you have to re-execute the command to start your script.') sys.exit(1) -except ImportError as e: # raised in textlib +except ImportError as e: # raised in textlib or backports sys.exit(e)