From d1564bffb9521f36ea8c958cc6ffd524fbb4d556 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 1 Aug 2013 22:24:51 -0400 Subject: [PATCH] support global-requirements.txt We are changing the upstream requirements.txt and test-requirements.txt to a combinded global-requirements.txt. Changes the checking script to support this as a possible file as well. This should be a seemless backwards compatible change. While modifying this file, also fix the flake8 style issues. Change-Id: I95ccd6f721a2c7f4e873d1de171d569bae0631e8 --- .../project-requirements-change.py | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/modules/jenkins/files/slave_scripts/project-requirements-change.py b/modules/jenkins/files/slave_scripts/project-requirements-change.py index c68d92b67f..13a18acf1c 100755 --- a/modules/jenkins/files/slave_scripts/project-requirements-change.py +++ b/modules/jenkins/files/slave_scripts/project-requirements-change.py @@ -23,6 +23,7 @@ import subprocess import sys import tempfile + def run_command(cmd): print(cmd) cmd_list = shlex.split(str(cmd)) @@ -31,6 +32,7 @@ def run_command(cmd): (out, nothing) = p.communicate() return out.strip() + class RequirementsList(object): def __init__(self, name): self.name = name @@ -55,17 +57,31 @@ class RequirementsList(object): self.failed = True self.reqs[req.project_name.lower()] = req - def read_all_requirements(self, include_dev=False): - for fn in ['tools/pip-requires', - 'tools/test-requires', - 'requirements.txt', - 'test-requirements.txt', - ]: - self.read_requirements(fn) + def read_all_requirements(self, global_req=False, include_dev=False): + """ Read all the requirements into a list. + + Build ourselves a consolidated list of requirements. If global_req is + True then we are parsing the global requirements file only, and + ensure that we don't parse it's test-requirements.txt erroneously. + + If include_dev is true allow for development requirements, which + may be prereleased versions of libraries that would otherwise be + listed. This is most often used for olso prereleases. + """ + if global_req: + self.read_requirements('global-requirements.txt') + else: + for fn in ['tools/pip-requires', + 'tools/test-requires', + 'requirements.txt', + 'test-requirements.txt' + ]: + self.read_requirements(fn) if include_dev: self.read_requirements('dev-requirements.txt', ignore_dups=True) + def main(): branch = sys.argv[1] head = run_command("git rev-parse HEAD").strip() @@ -88,7 +104,8 @@ def main(): print "requirements git sha: %s" % run_command( "git rev-parse HEAD").strip() os_reqs = RequirementsList('openstack/requirements') - os_reqs.read_all_requirements(include_dev=(branch=='master')) + os_reqs.read_all_requirements(include_dev=(branch == 'master'), + global_req=True) failed = False for req in head_reqs.reqs.values():