diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 1cc7f662244..33404e36081 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -239,6 +239,18 @@ def add_options(self) -> None: ), ) + self.cmd_opts.add_option( + "--dry-run", + action="store_true", + dest="dry_run", + default=False, + help=( + "Don't actually install anything, just print what would be. " + "Can be used in combination with --report and --ignore-installed " + "to 'resolve' the requirements." + ), + ) + self.cmd_opts.add_option(cmdoptions.no_binary()) self.cmd_opts.add_option(cmdoptions.only_binary()) self.cmd_opts.add_option(cmdoptions.prefer_binary()) @@ -361,6 +373,10 @@ def run(self, options: Values, args: List[str]) -> int: with open(options.json_report_file, "w") as f: json.dump(report.to_json(), f) + if options.dry_run: + # TODO print something useful here + return SUCCESS + try: pip_req = requirement_set.get_requirement("pip") except KeyError: