Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement `--executable' option (#257)
Browse files Browse the repository at this point in the history
Taylor R Campbell committed Jan 28, 2025
1 parent 4c9fd28 commit b912532
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/installer/__main__.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,13 @@ def _get_main_parser() -> argparse.ArgumentParser:
type=str,
help="override prefix to install packages to",
)
parser.add_argument(
"--executable",
metavar="path",
default=sys.executable,
type=str,
help="#! executable to install scripts with (default=sys.executable)",
)
parser.add_argument(
"--compile-bytecode",
action="append",
@@ -103,7 +110,7 @@ def _main(cli_args: Sequence[str], program: Optional[str] = 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.executable,
script_kind=get_launcher_kind(),
bytecode_optimization_levels=bytecode_levels,
destdir=args.destdir,
22 changes: 22 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -74,6 +74,28 @@ def test_main_prefix(fancy_wheel, tmp_path):
}


def test_main_executable(fancy_wheel, tmp_path):
destdir = tmp_path / "dest"

main(
[
str(fancy_wheel),
"-d",
str(destdir),
"--executable",
"/monty/python3.x",
],
"python -m installer",
)

installed_scripts = destdir.rglob("bin/*")

for f in installed_scripts:
with f.open("rb") as fp:
shebang = fp.readline()
assert shebang == b"#!/monty/python3.x\n"


def test_main_no_pyc(fancy_wheel, tmp_path):
destdir = tmp_path / "dest"

0 comments on commit b912532

Please sign in to comment.