From 2ca2b4b49367d6033bdd2c5e47d17392e7aba318 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 6 Feb 2012 09:49:09 -0500 Subject: Updated tox config for multi-python testing. Change-Id: Ib1f768c6783db0e63cb51dfc767ae5a31a295c76 --- .gitignore | 4 ++++ MANIFEST.in | 3 +++ openstack/common/setup.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 11 ----------- setup.py | 27 +++++++++++++-------------- tools/pip-requires | 14 +++++++------- tools/test-requires | 10 ++++++++++ tox.ini | 31 +++++++++++++++++++++++++++++-- 8 files changed, 111 insertions(+), 34 deletions(-) create mode 100644 MANIFEST.in create mode 100644 tools/test-requires diff --git a/.gitignore b/.gitignore index 3573288..bb370ba 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,11 @@ *.pyc *.log .coverage +requirements.txt +.venv +.tox cover/ +openstack.common.egg-info/ .openstack-common-venv/ skeleton.egg-info/ build/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..958d5d3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include requirements.txt +include tox.ini +include tools/* diff --git a/openstack/common/setup.py b/openstack/common/setup.py index 7966cf7..28f5e6f 100644 --- a/openstack/common/setup.py +++ b/openstack/common/setup.py @@ -40,3 +40,48 @@ def str_dict_replace(s, mapping): for s1, s2 in mapping.iteritems(): s = s.replace(s1, s2) return s + + +# Get requirements from the first file that exists +def get_reqs_from_files(requirements_files): + reqs_in = [] + for requirements_file in requirements_files: + if os.path.exists(requirements_file): + return open(requirements_file, 'r').read().split('\n') + return [] + + +def parse_requirements(requirements_files=['requirements.txt', + 'tools/pip-requires']): + requirements = [] + for line in get_reqs_from_files(requirements_files): + if re.match(r'\s*-e\s+', line): + requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', + line)) + elif re.match(r'\s*-f\s+', line): + pass + else: + requirements.append(line) + + return requirements + + +def parse_dependency_links(requirements_files=['requirements.txt', + 'tools/pip-requires']): + dependency_links = [] + for line in get_reqs_from_files(requirements_files): + if re.match(r'(\s*#)|(\s*$)', line): + continue + if re.match(r'\s*-[ef]\s+', line): + dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line)) + return dependency_links + + +def write_requirements(): + venv = os.environ.get('VIRTUAL_ENV', None) + if venv is not None: + with open("requirements.txt", "w") as req_file: + output = subprocess.Popen(["pip", "-E", venv, "freeze", "-l"], + stdout=subprocess.PIPE) + requirements = output.communicate()[0].strip() + req_file.write(requirements) diff --git a/setup.cfg b/setup.cfg index 2ce0f72..5a4689c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,17 +5,6 @@ # openstack-nose https://github.com/jkoelker/openstack-nose verbosity=2 detailed-errors=1 -with-coverage=1 -cover-package=openstack.common -cover-html=1 -cover-inclusive=1 -with-tissue=1 -tissue-repeat=1 -tissue-show-pep8=1 -tissue-show-source=1 -tissue-inclusive=1 -tissue-color=1 -tissue-package=openstack.common with-openstack=1 openstack-red=0.05 openstack-yellow=0.025 diff --git a/setup.py b/setup.py index 2c0c917..0f7e1c1 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,18 @@ from setuptools import setup, find_packages +from openstack.common.setup import parse_requirements +from openstack.common.setup import parse_dependency_links +from openstack.common.setup import write_requirements + version = '0.1' +requires = parse_requirements(['requirements.txt', 'tools/pip-requires']) + +depend_links = parse_dependency_links(['requirements.txt', + 'tools/pip-requires']) + +write_requirements() + setup(name='openstack.common', version=version, description="Common components for Openstack", @@ -23,20 +34,8 @@ Common components for Openstack including paster templates. packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=True, - install_requires=[ - 'greenlet>=0.3.1', - 'pep8', - 'pylint', - 'eventlet', - 'PasteDeploy', - 'routes', - 'webob', - 'nose', - 'nose-exclude', - 'mock', - 'webtest', - 'lxml', - ], + install_requires=requires, + dependency_links=depend_links, entry_points=""" # -*- Entry points: -*- """, diff --git a/tools/pip-requires b/tools/pip-requires index f197074..b9b28e1 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -1,9 +1,9 @@ -routes==1.12.3 -WebOb==1.0.8 -mox==0.5.3 PasteDeploy==1.5.0 +WebOb==1.0.8 eventlet -nose -coverage -tissue -openstack.nose_plugin +greenlet>=0.3.1 +lxml +mock +mox==0.5.3 +routes==1.12.3 +webtest diff --git a/tools/test-requires b/tools/test-requires new file mode 100644 index 0000000..2ae4497 --- /dev/null +++ b/tools/test-requires @@ -0,0 +1,10 @@ +# Packages needed for dev testing +distribute>=0.6.24 + +coverage +nose +nose-exclude +nosexcover +openstack.nose_plugin +pep8==0.6.1 +pylint diff --git a/tox.ini b/tox.ini index 5196177..1f14bab 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,38 @@ [tox] -envlist = py26,py27 +envlist = py26,py27,pep8 [testenv] +setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/tools/pip-requires + -r{toxinidir}/tools/test-requires commands = nosetests [testenv:pep8] deps = pep8 -commands = nosetests --with-tissue +commands = pep8 --repeat --show-source openstack setup.py + +[testenv:pylint] +deps = pylint +commands = pylint --rcfile=pylintrc --output-format=parseable openstack + +[testenv:cover] +commands = nosetests --with-coverage --cover-html --cover-erase --cover-package=openstack + +[testenv:sdist] +commands = python setup.py sdist {posargs} + +[testenv:hudson] +downloadcache = ~/cache/pip + +[testenv:jenkins26] +basepython = python2.6 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkins27] +basepython = python2.7 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkinscover] +deps = file://{toxinidir}/.cache.bundle +commands = nosetests --cover-erase --cover-package=openstack --with-xcoverage -- cgit