From 9a428f3ddbc5b17ec759d2ea5654bc33eb155dbf Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Fri, 24 Jun 2016 11:36:24 +1000 Subject: [PATCH] Check for missing run-time requirements This change creates a new tox environment that *only* installs openstack_requirements and then verifies that each of the console scripts has all of the modules that it imports. This will need to be added to our gate RSN Change-Id: Ibc37593afcc4d9f820cb88168e1aa15e773b2087 --- tools/check-install.py | 29 +++++++++++++++++++++++++++++ tox.ini | 15 ++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/check-install.py diff --git a/tools/check-install.py b/tools/check-install.py new file mode 100644 index 0000000000..14fc45116b --- /dev/null +++ b/tools/check-install.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import ConfigParser +import importlib +import re +import sys + + +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()) diff --git a/tox.ini b/tox.ini index 4a57dd1723..46019e2378 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,10 @@ [tox] minversion = 1.6 skipsdist = True -envlist = validate,py27,pep8 +envlist = validate,py27,pep8,pip-install [testenv] +basepython = python2.7 usedevelop = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} @@ -36,6 +37,18 @@ commands = flake8 [testenv:docs] commands = python setup.py build_sphinx +[testenv:pip-install] +recreate = True +deps = . +install_command = pip install {opts} {packages} +commands = python {toxinidir}/tools/check-install.py + +[testenv:py34] +basepython = python3.4 + +[testenv:py35] +basepython = python3.5 + [testenv:babel] # Use the local upper-constraints.txt file deps = Babel