diff options
-rw-r--r-- | pip/commands/install.py | 22 |
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 |