jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/725719 )
Change subject: [IMPR] Validate setuptools only once ......................................................................
[IMPR] Validate setuptools only once
check_modules function is called every time pwb.py is executed but called a second time if a script is invoked. Run this check only once.
Change-Id: If7a8541b362ecdf38571679b82eaee73a4429d24 --- M pwb.py 1 file changed, 18 insertions(+), 15 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py index f93eeb9..b8ddd82 100755 --- a/pwb.py +++ b/pwb.py @@ -182,27 +182,30 @@ """ import pkg_resources
- from setup import dependencies, script_deps + from setup import script_deps
missing_requirements = [] version_conflicts = []
- try: - requirement = next(pkg_resources.parse_requirements(dependencies)) - except ValueError as e: - # T286980: setuptools is too old and requirement parsing fails - import setuptools - setupversion = tuple(int(num) - for num in setuptools.__version__.split('.')) - if setupversion < (20, 8, 1): - # print the minimal requirement - _print_requirements(['setuptools==20.8.1'], None, - 'outdated ({})'.format(setuptools.__version__)) - return False - raise e - if script: dependencies = script_deps.get(Path(script).name, []) + else: + from setup import dependencies + try: + next(pkg_resources.parse_requirements(dependencies)) + except ValueError as e: + # T286980: setuptools is too old and requirement parsing fails + import setuptools + setupversion = tuple(int(num) + for num in setuptools.__version__.split('.')) + if setupversion < (20, 8, 1): + # print the minimal requirement + _print_requirements( + ['setuptools>=20.8.1'], None, + 'outdated ({})'.format(setuptools.__version__)) + return False + raise e + for requirement in pkg_resources.parse_requirements(dependencies): if requirement.marker is None \ or pkg_resources.evaluate_marker(str(requirement.marker)):
pywikibot-commits@lists.wikimedia.org