summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-10-17 12:02:57 +0100
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-11-21 10:53:08 +0000
commitea680f204fb0e48789710c22c8f597a9bf01bc16 (patch)
tree5f331db9f3d5a166b80a5332c17c496a75faf346
parent08ebc0a8bd5ea5e407caef8b5b0c265bdd7f5876 (diff)
downloadpip-ea680f204fb0e48789710c22c8f597a9bf01bc16.tar.gz
-rw-r--r--pip/commands/install.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pip/commands/install.py b/pip/commands/install.py
index cbf22a086..4589130cb 100644
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -160,6 +160,13 @@ class InstallCommand(Command):
cmd_opts.add_option(cmdoptions.no_clean.make())
+ cmd_opts.add_option(
+ '--list-dependencies',
+ dest="list_dependencies",
+ metavar="file",
+ default=None,
+ help="Don't install anything, write all dependencies into <file>")
+
index_opts = cmdoptions.make_option_group(cmdoptions.index_group, self.parser)
self.parser.insert_option_group(0, index_opts)
@@ -183,6 +190,14 @@ class InstallCommand(Command):
session=session,
)
+ def write_dependencies_to_file(self, path, requirements):
+ def strspecs(specs):
+ return ''.join(['%s%s,' % (op, ver) for (op, ver) in specs]).rstrip(',')
+
+ with open(path, 'w') as f:
+ for req in requirements.values():
+ f.write('%s%s\n' % (req.name, strspecs(req.req.specs)))
+
def run(self, options, args):
if (
@@ -252,6 +267,7 @@ class InstallCommand(Command):
session=session,
pycompile=options.compile,
)
+
for name in args:
requirement_set.add_requirement(
InstallRequirement.from_line(name, None))
@@ -274,11 +290,17 @@ class InstallCommand(Command):
return
try:
+ # Obtain requirement set
if not options.no_download:
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
else:
requirement_set.locate_files()
+ if options.list_dependencies:
+ self.write_dependencies_to_file(options.list_dependencies,
+ requirement_set.requirements)
+ return
+
if not options.no_install and not self.bundle:
requirement_set.install(install_options, global_options, root=options.root_path)
installed = ' '.join([req.name for req in