Normalize global-requirements.txt

This enforces consistent spacing in global-requirements.txt
and sorts the specifiers to be always in a specific order
(namely minimum bound first, then exceptions, then upper bound).

Add test coverage for this normalisation.

Change-Id: If41732bfe4476e422bc6b9f9f896eb978db8be84
This commit is contained in:
Dirk Mueller 2017-10-24 15:26:44 +02:00 committed by Tony Breeds
parent 869832ffa6
commit 4f54188c61
3 changed files with 106 additions and 94 deletions

View File

@ -3,7 +3,7 @@
astroid
bandit
flake8
flake8_docstrings
flake8-docstrings
flake8-import-order
hacking
mccabe

View File

@ -34,10 +34,10 @@ dib-utils>=0.0.8 # Apache-2.0
diskimage-builder>=1.1.2,!=1.6.0,!=1.7.0,!=1.7.1 # Apache-2.0
Django>=1.8,<2.0 # BSD
django-babel>=0.5.1 # BSD
django_compressor>=2.0 # MIT
django-compressor>=2.0 # MIT
django-floppyforms>=1.0,<2 # BSD
django-formtools>=1.0 # BSD
django_openstack_auth>=3.5.0 # Apache-2.0
django-openstack-auth>=3.5.0 # Apache-2.0
dnspython>=1.14.0;python_version=='2.7' # http://www.dnspython.org/LICENSE
dnspython3>=1.12.0,!=1.13.0,!=1.14.0;python_version>='3.0' # http://www.dnspython.org/LICENSE
# Note(tonyb): We don't actually directly depend on docutils but we pull it in
@ -53,7 +53,7 @@ enum34>=1.0.4;python_version=='2.7' or python_version=='2.6' or python_version==
# as they have earned a reputation of frequently breaking things.
# NOTE(sdague): before allowing in >= 0.21 please be sure
# https://github.com/eventlet/eventlet/issues/401 is resolved
eventlet!=0.18.3,>=0.18.2,!=0.20.1,<0.21.0 # MIT
eventlet>=0.18.2,!=0.18.3,!=0.20.1,<0.21.0 # MIT
exabgp>=4.0.1 # BSD
extras>=0.0.3 # MIT
falcon>=1.0.0 # Apache-2.0
@ -67,7 +67,7 @@ futures>=3.0;python_version=='2.7' or python_version=='2.6' # BSD
futurist>=1.2.0 # Apache-2.0
funcsigs>=1.0.0;python_version=='2.7' or python_version=='2.6' # Apache-2.0
gitdb>=0.6.4 # BSD License (3 clause)
glance_store>=0.22.0 # Apache-2.0
glance-store>=0.22.0 # Apache-2.0
google-api-python-client>=1.4.2 # Apache-2.0
graphviz>=0.4,!=0.5.0 # MIT License
greenlet>=0.4.10 # MIT
@ -289,7 +289,7 @@ rfc3986>=0.3.1 # Apache-2.0
Routes>=2.3.1 # MIT
rtslib-fb>=2.1.43,!=2.1.60,!=2.1.61 # Apache-2.0
ryu>=4.14 # Apache-2.0
semantic_version>=2.3.1 # BSD
semantic-version>=2.3.1 # BSD
fasteners>=0.7.0 # Apache-2.0
scrypt>=0.8.0 # BSD
simplejson>=3.5.1 # MIT
@ -306,7 +306,7 @@ sqlalchemy-migrate>=0.11.0 # Apache-2.0
sqlparse>=0.2.2 # BSD
stevedore>=1.20.0 # Apache-2.0
systemd-python>=234 # LGPLv2+
sysv_ipc>=0.6.8 # BSD License
sysv-ipc>=0.6.8 # BSD License
suds-jurko>=0.6 # LGPLv3+
sympy>=0.7.6 # BSD
taskflow>=2.7.0 # Apache-2.0
@ -388,7 +388,7 @@ nose-exclude>=0.3.0 # LGPL
nosehtmloutput>=0.0.3 # Apache-2.0
nosexcover>=1.0.10 # BSD
openstack-doc-tools>=1.5.0 # Apache-2.0
openstack.nose_plugin>=0.7 # Apache-2.0
openstack.nose-plugin>=0.7 # Apache-2.0
openstacksdk>=0.9.18 # Apache-2.0
os-api-ref>=1.4.0 # Apache-2.0
oslosphinx>=4.7.0 # Apache-2.0
@ -406,7 +406,7 @@ hiredis>=0.2.0 # BSD
requests-mock>=1.1.0 # Apache-2.0
tenacity>=3.2.1 # Apache-2.0
retrying>=1.2.3,!=1.3.0 # Apache-2.0
spec_cleaner>=0.8.2,!=0.9.3 # BSD
spec-cleaner>=0.8.2,!=0.9.3 # BSD
selenium>=2.50.1 # Apache-2.0
# While setuptools cannot deal with pre-installed incompatible versions,
# setting a lower bound is not harmful - it makes error messages cleaner. DO
@ -441,7 +441,7 @@ WebTest>=2.0.27 # MIT
Werkzeug>=0.7 # BSD License
whereto>=0.3.0 # Apache-2.0
xmltodict>=0.10.1 # MIT
wsgi_intercept>=1.4.1 # MIT License
wsgi-intercept>=1.4.1 # MIT License
xvfbwrapper>=0.1.3 #license: MIT
zake>=0.1.6 # Apache-2.0
zuul-sphinx>=0.1.2 # Apache-2.0

View File

@ -67,6 +67,18 @@ def main():
print(msg)
error_count += 1
# Check that global requirements are uniformly formatted
print('\nValidating uniform formatting on %s' % args.global_requirements)
with open(args.global_requirements, 'rt') as f:
for line in f:
if line == '\n':
continue
req = requirement.parse_line(line)
normed_req = req.to_line(comment_prefix=' ', sort_specifiers=True)
if line.rstrip() != normed_req.rstrip():
print("-%s\n+%s" % (line.rstrip(), normed_req.rstrip()))
error_count += 1
# Check that all of the items in the global-requirements list
# appear in exactly one of the constraints file or the blacklist.
print('\nChecking %s' % args.blacklist)