jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/578002 )
Change subject: [IMPR] Check for all modules which are needed by a script ......................................................................
[IMPR] Check for all modules which are needed by a script
This patch enables checking for all required modules which are needed by a script for a give Python release. This ensures that the package has to be updated if necessary but always run a script with -help option.
Change-Id: I201d05f147abd0bb2bd552586a351af0fc606124 --- M pwb.py 1 file changed, 16 insertions(+), 6 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py index f741091..228c307 100755 --- a/pwb.py +++ b/pwb.py @@ -139,10 +139,19 @@ return fname, list(args[index + int(bool(fname)):]), args[:index]
-def check_modules(): +def check_modules(script=None): """Check whether mandatory modules are present.""" import pkg_resources - from setup import dependencies + if script: + from setup import script_deps + try: + from pathlib import Path + except ImportError: # Python 2 + from pathlib2 import Path + dependencies = script_deps.get(Path(script).name, []) + else: + from setup import dependencies + missing_requirements = []
for requirement in pkg_resources.parse_requirements(dependencies): @@ -347,10 +356,11 @@ warn('Parent module %s not found: %s' % (file_package, e), ImportWarning)
- run_python_file(filename, - [filename] + args, - [Path(relative_filename).stem] + argvu[1:], - file_package) + if check_modules(filename) or '-help' in args: + run_python_file(filename, + [filename] + args, + [Path(relative_filename).stem] + argvu[1:], + file_package) return True