From dec28be1ab2099eae56a621dc247fd2148f5b79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 30 Apr 2022 11:41:50 +0200 Subject: [PATCH] DRAFT - pip install --dry-run --- src/pip/_internal/commands/install.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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: