| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | from __future__ import print_function |
| 21 | import importlib
|
| 22 | import sys
|
| 23 | import traceback
|
| 24 | try:
|
| 25 | import pkg_resources
|
| 26 | except ImportError:
|
| 27 | print('Warning: Skipping, because python-setuptools are not available.')
|
| 28 | sys.exit(0)
|
| 29 |
|
| 30 | try:
|
| 31 | from importlib.machinery import PathFinder
|
| 32 | except ImportError:
|
| 33 | PathFinder = None
|
| 34 |
|
| 35 | ret = 0
|
| 36 |
|
| 37 | |
| 38 | |
| 39 | ws = pkg_resources.find_distributions(sys.argv[1])
|
| 40 |
|
| 41 | for dist in ws:
|
| 42 | print('validating', repr(dist.project_name), dist.location)
|
| 43 | try:
|
| 44 | print('...checking requirements: ', end='')
|
| 45 | req = str(dist.as_requirement())
|
| 46 | |
| 47 | |
| 48 | pkg_resources.require(req)
|
| 49 | print('OK')
|
| 50 | except Exception as e:
|
| 51 | print('ERROR:', req, repr(e))
|
| 52 | ret = 1
|
| 53 | continue
|
| 54 |
|
| 55 | |
| 56 | try:
|
| 57 | metalines = dist.get_metadata_lines('top_level.txt')
|
| 58 | except (KeyError, EnvironmentError):
|
| 59 | |
| 60 | |
| 61 | |
| 62 | print('WARNING: cannot determine top-level modules')
|
| 63 | continue
|
| 64 | for name in metalines:
|
| 65 | |
| 66 | if PathFinder and PathFinder.find_spec(name) is None:
|
| 67 | |
| 68 | |
| 69 | |
| 70 | continue
|
| 71 | try:
|
| 72 | print('...trying to load module', name, end=': ')
|
| 73 | importlib.import_module(name)
|
| 74 | print('OK')
|
| 75 | except Exception:
|
| 76 | print('ERROR:')
|
| 77 | traceback.print_exc(file=sys.stdout)
|
| 78 | ret = 1
|
| 79 |
|
| 80 | |
| 81 | |
| 82 | |
| 83 | for group, v in dist.get_entry_map().items():
|
| 84 | if group not in {'console_scripts', 'gui_scripts'}:
|
| 85 | continue
|
| 86 | for name, ep in v.items():
|
| 87 | try:
|
| 88 | print('...trying to load endpoint', group, name, end=': ')
|
| 89 | ep.load()
|
| 90 | print('OK')
|
| 91 | except Exception:
|
| 92 | print('ERROR:')
|
| 93 | traceback.print_exc(file=sys.stdout)
|
| 94 | ret = 1
|
| 95 |
|
| 96 | sys.exit(ret)
|