jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1203273?usp=email )

Change subject: IMPR: show friendly install message when mandatory packages are 
missing
......................................................................

IMPR: show friendly install message when mandatory packages are missing

Bug: T409662
Change-Id: Iad29a2c5afe1a6c9b8443e6b7c0306ea2be055f6
---
M pywikibot/scripts/wrapper.py
1 file changed, 11 insertions(+), 3 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py
index eff65f6..906c8a1 100755
--- a/pywikibot/scripts/wrapper.py
+++ b/pywikibot/scripts/wrapper.py
@@ -220,8 +220,9 @@
     else:
         format_string = '\nA package necessary for {} is {}.'
     print(format_string.format(script or 'pywikibot', variant))
-    print('Please update required module{} with:\n\n'
-          .format('s' if len(requirements) > 1 else ''))
+    print('Please {} required module{} with:\n\n'
+          .format('install' if variant == 'missing' else 'update',
+                  's' if len(requirements) > 1 else ''))

     for requirement in requirements:
         print(f"    pip install \"{str(requirement).partition(';')[0]}\"\n")
@@ -237,7 +238,11 @@
     :return: True if all dependencies are installed
     :raise RuntimeError: wrong Python version found in setup.py
     """
-    from packaging.requirements import Requirement
+    try:
+        from packaging.requirements import Requirement
+    except ModuleNotFoundError:
+        _print_requirements(['packaging'], None, 'missing')
+        sys.exit()

     from setup import script_deps

@@ -289,6 +294,9 @@
     return not missing_requirements


+if not check_modules():
+    sys.exit()
+
 filename, script_args, global_args, environ = handle_args(*sys.argv)

 # Search for user config file (user-config.py) before creating one.

-- 
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1203273?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iad29a2c5afe1a6c9b8443e6b7c0306ea2be055f6
Gerrit-Change-Number: 1203273
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to