From 035abae6ef6c87f7439392de955e3c55882bfa73 Mon Sep 17 00:00:00 2001 From: ChenZheng Date: Thu, 27 Feb 2014 14:49:09 +0800 Subject: [PATCH] Sort requirement files in alphabetical order This makes code more readable, and can check whether specific library in the requirement files easily. We also enforce the check in pep8. Change-Id: I032c3c3d29522ce85f64b21d6428d975e46cc701 Closes-Bug: #1285478 --- requirements.txt | 34 +++++++++++++++---------------- test-requirements.txt | 15 +++++++------- tools/requirements_style_check.sh | 32 +++++++++++++++++++++++++++++ tox.ini | 1 + 4 files changed, 57 insertions(+), 25 deletions(-) create mode 100755 tools/requirements_style_check.sh diff --git a/requirements.txt b/requirements.txt index 7399f73d2b..aea5222e6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,30 +1,30 @@ -pbr>=0.6,!=0.7,<1.0 -pycrypto>=2.6 +argparse +Babel>=1.3 eventlet>=0.13.0 greenlet>=0.3.2 httplib2>=0.7.5 iso8601>=0.1.9 kombu>=2.4.8 -argparse lxml>=2.3 netaddr>=0.7.6 -six>=1.5.2 -sqlalchemy-migrate>=0.8.2,!=0.8.4 -python-novaclient>=2.17.0 +oslo.config>=1.2.0 +paramiko>=1.9.0 PasteDeploy>=1.5.0 -requests>=1.1 -Routes>=1.12.3 -SQLAlchemy>=0.7.8,<=0.9.99 -WebOb>=1.2.3 -python-heatclient>=0.2.3 -python-keystoneclient>=0.7.0 -python-swiftclient>=1.6 -python-neutronclient>=2.3.4,<3 +pbr>=0.6,!=0.7,<1.0 +pycrypto>=2.6 python-ceilometerclient>=1.0.6 python-cinderclient>=1.0.6 +python-heatclient>=0.2.3 +python-keystoneclient>=0.7.0 +python-neutronclient>=2.3.4,<3 +python-novaclient>=2.17.0 +python-swiftclient>=1.6 python-troveclient>=1.0.3 PyYAML>=3.1.0 -paramiko>=1.9.0 -Babel>=1.3 -oslo.config>=1.2.0 qpid-python +requests>=1.1 +Routes>=1.12.3 +six>=1.5.2 +SQLAlchemy>=0.7.8,<=0.9.99 +sqlalchemy-migrate>=0.8.2,!=0.8.4 +WebOb>=1.2.3 diff --git a/test-requirements.txt b/test-requirements.txt index f8aab68375..c026078330 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,14 +1,13 @@ -# Hacking already pins down pep8, pyflakes and flake8 -hacking>=0.8.0,<0.9 - coverage>=3.6 discover +# Hacking already pins down pep8, pyflakes and flake8 +hacking>=0.8.0,<0.9 +lockfile>=0.8 mock>=1.0 mox>=0.5.3 -testtools>=0.9.34 -testrepository>=0.0.18 -testscenarios>=0.4 +oslosphinx python-glanceclient>=0.9.0 sphinx>=1.1.2,<1.2 -oslosphinx -lockfile>=0.8 +testrepository>=0.0.18 +testscenarios>=0.4 +testtools>=0.9.34 diff --git a/tools/requirements_style_check.sh b/tools/requirements_style_check.sh new file mode 100755 index 0000000000..ccbff3bddc --- /dev/null +++ b/tools/requirements_style_check.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Enforce the requirement that dependencies are listed in the input +# files in alphabetical order. + +# FIXME(dhellmann): This doesn't deal with URL requirements very +# well. We should probably sort those on the egg-name, rather than the +# full line. + +function check_file() { + typeset f=$1 + + # We don't care about comment lines. + grep -v '^#' $f > ${f}.unsorted + sort -i -f ${f}.unsorted > ${f}.sorted + diff -c ${f}.unsorted ${f}.sorted + rc=$? + rm -f ${f}.sorted ${f}.unsorted + return $rc +} + +exit_code=0 +for filename in $@ +do + check_file $filename + if [ $? -ne 0 ] + then + echo "Please list requirements in $filename in alphabetical order" 1>&2 + exit_code=1 + fi +done +exit $exit_code diff --git a/tox.ini b/tox.ini index 4e0cf16176..c0b5ffdbfa 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ commands = flake8 heat bin/heat-api bin/heat-api-cfn bin/heat-api-cloudwatch bin/heat-engine bin/heat-manage contrib # disable check_uptodate until a resolution is found to bug #1288586 #{toxinidir}/tools/config/check_uptodate.sh + {toxinidir}/tools/requirements_style_check.sh requirements.txt test-requirements.txt [testenv:venv] commands = {posargs}