Complying with

http://wiki.openstack.org/ProjectTestingInterface

Fixes: bug 1083835
Change-Id: I31f525c62cdb3b4c7eb695b6a431e4df6443f673
This commit is contained in:
Josh Dorothy 2012-11-27 12:56:13 -08:00
parent 52389f90f2
commit 7079d5054a
4 changed files with 66 additions and 17 deletions

View File

@ -17,15 +17,47 @@
# under the License.
import os
import re
import setuptools
import sys
requirements = ["httplib2", "lxml", "prettytable"]
if sys.version_info < (2, 6):
requirements.append("simplejson")
if sys.version_info < (2, 7):
requirements.append("argparse")
# Get requirements from the first file that exists
def get_reqs_from_files(requirements_files):
for requirements_file in requirements_files:
if os.path.exists(requirements_file):
with open(requirements_file, 'r') as fil:
return fil.read().split('\n')
return []
def parse_requirements(requirements_files=['requirements.txt',
'tools/pip-requires']):
requirements = []
for line in get_reqs_from_files(requirements_files):
# For the requirements list, we need to inject only the portion
# after egg= so that distutils knows the package it's looking for
# such as:
# -e git://github.com/openstack/nova/master#egg=nova
if re.match(r'\s*-e\s+', line):
requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1',
line))
# such as:
# http://github.com/openstack/nova/zipball/master#egg=nova
elif re.match(r'\s*https?:', line):
requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1',
line))
# -f lines are for index locations, and don't get used here
elif re.match(r'\s*-f\s+', line):
pass
# argparse is part of the standard library starting with 2.7
# adding it to the requirements list screws distro installs
elif line == 'argparse' and sys.version_info >= (2, 7):
pass
else:
requirements.append(line)
return requirements
def read_file(file_name):
@ -41,8 +73,7 @@ setuptools.setup(
license="Apache License, Version 2.0",
url="https://github.com/openstack/python-reddwarfclient",
packages=["reddwarfclient"],
install_requires=requirements,
tests_require=["nose", "mock"],
install_requires=parse_requirements(),
test_suite="nose.collector",
classifiers=[
"Development Status :: 5 - Production/Stable",

4
tools/pip-requires Normal file
View File

@ -0,0 +1,4 @@
argparse>=1.2.1
httplib2>=0.7.7
lxml>=3.0.1
prettytable>=0.6.1

6
tools/test-requires Normal file
View File

@ -0,0 +1,6 @@
nose>=1.2.1
nosexcover>=1.0.7
openstack.nose_plugin>=0.11
pep8==1.1
sphinx>=1.1.2
unittest2>=0.5.1

28
tox.ini
View File

@ -1,16 +1,24 @@
# Python Reddwarf Client
[tox]
envlist = py26, docs
envlist = py26,py27,pep8
[testenv:docs]
deps =
coverage
httplib2
sphinx
commands =
sphinx-build -b doctest {toxinidir}/docs/source {envtmpdir}/html
sphinx-build -b html {toxinidir}/docs/source {envtmpdir}/html
[testenv]
setenv = VIRTUAL_ENV={envdir}
NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_COLOR=1
NOSE_OPENSTACK_RED=0.05
NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
commands = nosetests
[testenv:pep8]
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc reddwarfclient setup.py
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc reddwarfclient setup.py
[testenv:venv]
commands = {posargs}
[testenv:cover]
commands = nosetests --cover-erase --cover-package=reddwarfclient --with-xcoverage