From 22fa800b4cbcfddd57fa262fd7f2aeb06a15a711 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Mon, 14 Mar 2022 14:39:22 +0000 Subject: [PATCH] installer: add --interpreter option The currently running Python might not be the right one for the installed wheels, so add an option to allow the interpreter to be overridden. This is essential in cross/distro builds where we want to install a wheel into a working directory to build a distro package (eg a rpm or deb) with pypa/installer, but the currently running python on the build host might not be the right path for the scripts to use on the target. --- src/installer/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/installer/__main__.py b/src/installer/__main__.py index b7a7445d..25415ea0 100644 --- a/src/installer/__main__.py +++ b/src/installer/__main__.py @@ -30,6 +30,13 @@ def _get_main_parser() -> argparse.ArgumentParser: type=str, help="override prefix to install packages to", ) + parser.add_argument( + "--interpreter", + "-i", + type=str, + default=sys.executable, + help=f"interpreter (defaults to {sys.executable})", + ) parser.add_argument( "--compile-bytecode", action="append", @@ -102,7 +109,7 @@ def _main(cli_args: Sequence[str], program: str | None = None) -> None: source.validate_record(validate_contents=args.validate_record == "all") destination = SchemeDictionaryDestination( scheme_dict=_get_scheme_dict(source.distribution, prefix=args.prefix), - interpreter=sys.executable, + interpreter=args.interpreter, script_kind=get_launcher_kind(), bytecode_optimization_levels=bytecode_levels, destdir=args.destdir,