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
This commit is contained in:
parent
543d261e08
commit
1e588a8d40
@ -76,6 +76,8 @@ class Mirror(object):
|
|||||||
help='specify the config file')
|
help='specify the config file')
|
||||||
parser.add_argument('-n', dest='noop', action='store_true',
|
parser.add_argument('-n', dest='noop', action='store_true',
|
||||||
help='do not run any commands')
|
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',
|
parser.add_argument('--no-pip', dest='no_pip', action='store_true',
|
||||||
help='do not run any pip commands')
|
help='do not run any pip commands')
|
||||||
parser.add_argument('--verbose', dest='debug', action='store_true',
|
parser.add_argument('--verbose', dest='debug', action='store_true',
|
||||||
@ -235,16 +237,17 @@ class Mirror(object):
|
|||||||
if not self.args.no_update:
|
if not self.args.no_update:
|
||||||
git("reset --hard %s" % branch)
|
git("reset --hard %s" % branch)
|
||||||
git("clean -x -f -d -q")
|
git("clean -x -f -d -q")
|
||||||
reqlist = []
|
if self.args.reqlist:
|
||||||
if os.path.exists('global-requirements.txt'):
|
# Not filtering for existing files - they must all exist.
|
||||||
reqlist.append('global-requirements.txt')
|
reqlist = self.args.reqlist
|
||||||
|
elif os.path.exists('global-requirements.txt'):
|
||||||
|
reqlist = ['global-requirements.txt']
|
||||||
else:
|
else:
|
||||||
for requires_file in ("requirements.txt",
|
reqlist = [r for r in ["requirements.txt",
|
||||||
"test-requirements.txt",
|
"test-requirements.txt",
|
||||||
"tools/pip-requires",
|
"tools/pip-requires",
|
||||||
"tools/test-requires"):
|
"tools/test-requires"]
|
||||||
if os.path.exists(requires_file):
|
if os.path.exists(r)]
|
||||||
reqlist.append(requires_file)
|
|
||||||
if not reqlist:
|
if not reqlist:
|
||||||
print("no requirements")
|
print("no requirements")
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user