From 1e588a8d400340fba14f775d9fb87c2810acbb6a Mon Sep 17 00:00:00 2001 From: Manuel Desbonnet Date: Fri, 20 Jun 2014 11:31:02 +0100 Subject: [PATCH] Allow for specifying requirements files on the cmd-line Adding a '-r' parameter which allows for specifying one or more requirements files instead of the built-in 'global-requirements.txt' file. This is to enable building an internal pypi mirror using additional internal requirements files. Change-Id: I506a9beddf773d6290639ed4d01588339ad3f99c --- pypi_mirror/cmd/run_mirror.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pypi_mirror/cmd/run_mirror.py b/pypi_mirror/cmd/run_mirror.py index 2f98645..080d488 100644 --- a/pypi_mirror/cmd/run_mirror.py +++ b/pypi_mirror/cmd/run_mirror.py @@ -76,6 +76,8 @@ class Mirror(object): help='specify the config file') parser.add_argument('-n', dest='noop', action='store_true', help='do not run any commands') + parser.add_argument('-r', dest='reqlist', action='append', + help='specify alternative requirements file(s)') parser.add_argument('--no-pip', dest='no_pip', action='store_true', help='do not run any pip commands') parser.add_argument('--verbose', dest='debug', action='store_true', @@ -235,16 +237,17 @@ class Mirror(object): if not self.args.no_update: git("reset --hard %s" % branch) git("clean -x -f -d -q") - reqlist = [] - if os.path.exists('global-requirements.txt'): - reqlist.append('global-requirements.txt') + if self.args.reqlist: + # Not filtering for existing files - they must all exist. + reqlist = self.args.reqlist + elif os.path.exists('global-requirements.txt'): + reqlist = ['global-requirements.txt'] else: - for requires_file in ("requirements.txt", - "test-requirements.txt", - "tools/pip-requires", - "tools/test-requires"): - if os.path.exists(requires_file): - reqlist.append(requires_file) + reqlist = [r for r in ["requirements.txt", + "test-requirements.txt", + "tools/pip-requires", + "tools/test-requires"] + if os.path.exists(r)] if not reqlist: print("no requirements") continue