nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1diff --git a/src/installer/__main__.py b/src/installer/__main__.py
2index 51014b9..45682d0 100644
3--- a/src/installer/__main__.py
4+++ b/src/installer/__main__.py
5@@ -30,6 +30,13 @@ def _get_main_parser() -> argparse.ArgumentParser:
6 type=str,
7 help="override prefix to install packages to",
8 )
9+ parser.add_argument(
10+ "--executable",
11+ metavar="path",
12+ default=sys.executable,
13+ type=str,
14+ help="#! executable to install scripts with (default=sys.executable)",
15+ )
16 parser.add_argument(
17 "--compile-bytecode",
18 action="append",
19@@ -86,7 +93,7 @@ def _main(cli_args: Sequence[str], program: Optional[str] = None) -> None:
20 with WheelFile.open(args.wheel) as source:
21 destination = SchemeDictionaryDestination(
22 scheme_dict=_get_scheme_dict(source.distribution, prefix=args.prefix),
23- interpreter=sys.executable,
24+ interpreter=args.executable,
25 script_kind=get_launcher_kind(),
26 bytecode_optimization_levels=bytecode_levels,
27 destdir=args.destdir,
28@@ -94,5 +101,6 @@ def _main(cli_args: Sequence[str], program: Optional[str] = None) -> None:
29 installer.install(source, destination, {})
30
31
32+
33 if __name__ == "__main__": # pragma: no cover
34 _main(sys.argv[1:], "python -m installer")
35diff --git a/tests/test_main.py b/tests/test_main.py
36index 391a13d..d7b4192 100644
37--- a/tests/test_main.py
38+++ b/tests/test_main.py
39@@ -53,6 +53,28 @@ def test_main_prefix(fancy_wheel, tmp_path):
40 }
41
42
43+def test_main_executable(fancy_wheel, tmp_path):
44+ destdir = tmp_path / "dest"
45+
46+ main(
47+ [
48+ str(fancy_wheel),
49+ "-d",
50+ str(destdir),
51+ "--executable",
52+ "/monty/python3.x",
53+ ],
54+ "python -m installer",
55+ )
56+
57+ installed_scripts = destdir.rglob("bin/*")
58+
59+ for f in installed_scripts:
60+ with f.open("rb") as fp:
61+ shebang = fp.readline()
62+ assert shebang == b"#!/monty/python3.x\n"
63+
64+
65 def test_main_no_pyc(fancy_wheel, tmp_path):
66 destdir = tmp_path / "dest"
67