requirements/tools/check-install.py
Piotr Bielak de2adc5377 Fixed "pip-install" test
The "pip-install" tox environment was failing, because the name
of the "ConfigParser" package was changed into "configparser".
This commit fixes that by using the six.moves module to do the right
thing on py2 and py3

Change-Id: I6b16c8f0e182850cda041ca294edc5ad04c1a3c3
2018-08-01 12:56:57 +10:00

32 lines
799 B
Python

#!/usr/bin/env python
from __future__ import print_function
import importlib
import re
import sys
import six.moves.configparser as configparser
def main():
errors = 0
pattern = re.compile('^(.*?)\s*=\s*([^:]*?):.*$')
config = configparser.ConfigParser()
config.read('setup.cfg')
console_scripts = config.get('entry_points', 'console_scripts')
for script in console_scripts.split('\n'):
match = pattern.match(script)
if match:
(script, module) = match.groups()
try:
importlib.import_module(module)
except ImportError as err:
print('Imports for %s failed:\n\t%s' % (script, err))
errors += 1
return 1 if errors else 0
if __name__ == '__main__':
sys.exit(main())