Skip to content

Commit

Permalink
[fix] do not check for installed 'importlib_metadata' and 'packaging'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
xqt committed Jan 3, 2024
1 parent 40534fe commit bf5b373
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pywikibot/scripts/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit bf5b373

Please sign in to comment.