From 249063daf0b5890f740334e2108437c1558c7ab0 Mon Sep 17 00:00:00 2001 From: Fengqian Gao Date: Fri, 28 Feb 2014 12:41:11 +0800 Subject: [PATCH] Sort requirement files in alphabetical order Sort requirement files in alphabetical order and enforce pep8 check. Partial-Bug: #1285478 Change-Id: I0ff79651df9529a7c8da87cc51dcf0a1594702f9 --- requirements.txt | 28 +++++++++++++-------------- test-requirements.txt | 11 +++++------ tools/requirements_style_check.sh | 32 +++++++++++++++++++++++++++++++ tox.ini | 1 + 4 files changed, 52 insertions(+), 20 deletions(-) create mode 100755 tools/requirements_style_check.sh diff --git a/requirements.txt b/requirements.txt index e0b08333..6feaf395 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,24 +1,24 @@ -pbr>=0.5.21,<1.0 -SQLAlchemy>=0.7.8,<=0.7.99 + amqplib>=0.6.1 anyjson>=0.3.3 argparse +Babel>=1.3 +-e git+http://git.openstack.org/cgit/openstack/tripleo-heat-templates#egg=tripleo_heat_templates-master eventlet>=0.13.0 +Flask>=0.10,<1.0 +greenlet>=0.3.2 +iso8601>=0.1.8 kombu>=2.4.8 lxml>=2.3 -WebOb>=1.2.3,<1.3 -greenlet>=0.3.2 -sqlalchemy-migrate>=0.8.2 -Babel>=1.3 -iso8601>=0.1.8 -setuptools_git>=0.4 -python-keystoneclient>=0.4.1 oslo.config>=1.2.0 -Flask>=0.10,<1.0 +pbr>=0.5.21,<1.0 pecan>=0.2.0 -WSME>=0.5b6 +python-heatclient>=0.2.3 +python-keystoneclient>=0.4.1 python-novaclient>=2.15.0 PyYAML>=3.1.0 -python-heatclient>=0.2.3 - --e git+http://git.openstack.org/cgit/openstack/tripleo-heat-templates#egg=tripleo_heat_templates-master +setuptools_git>=0.4 +SQLAlchemy>=0.7.8,<=0.7.99 +sqlalchemy-migrate>=0.8.2 +WebOb>=1.2.3,<1.3 +WSME>=0.5b6 diff --git a/test-requirements.txt b/test-requirements.txt index ab01f809..9fffaa30 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,18 +1,17 @@ -# Hacking already pins down pep8, pyflakes and flake8 -hacking>=0.8.0,<0.9 coverage>=3.6 discover fixtures>=0.3.14 +# Hacking already pins down pep8, pyflakes and flake8 +hacking>=0.8.0,<0.9 mock>=1.0 mox>=0.5.3 MySQL-python python-subunit +# Doc requirements +sphinx>=1.1.2,<1.2 +sphinxcontrib-pecanwsme>=0.5 stevedore>=0.14 testrepository>=0.0.17 testtools>=0.9.32 unittest2 - -# Doc requirements -sphinx>=1.1.2,<1.2 -sphinxcontrib-pecanwsme>=0.5 diff --git a/tools/requirements_style_check.sh b/tools/requirements_style_check.sh new file mode 100755 index 00000000..ccbff3bd --- /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 6677585b..18793aa6 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ downloadcache = ~/cache/pip [testenv:pep8] commands = flake8 + {toxinidir}/tools/requirements_style_check.sh requirements.txt test-requirements.txt [testenv:cover] setenv = VIRTUAL_ENV={envdir}