Skip to content
Myr

detect exe name when using shiv/pex

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Fredrik Mellström · committed by David Lord · parent 6e70405 · Browse files · 3 files+4 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+4 added−1 removed

  • tests:+1 added−0 removed
  • other:+3 added−1 removed

3 files+4 added−1 removed

modified:src/click/utils.py+2 added-1 removed
521 unmodified lines
522523 # The value of __package__ indicates how Python was called. It may524 # not exist if a setuptools script is installed as an egg. It may be525 # set incorrectly for entry points created with pip on Windows.526 # It is set to "" inside a Shiv or PEX zipapp.526 if getattr(_main, "__package__", None) is None or (527 if getattr(_main, "__package__", None) in {None, ""} or (528 os.name == "nt"529 and _main.__package__ == ""530 and not os.path.exists(path)531 and os.path.exists(f"{path}.exe")
67 unmodified lines
modified:tests/test_utils.py+1 added
444 unmodified lines
445 (str(pathlib.Path("/foo/bar/example.py")), None, "example.py"),446 ("example", None, "example"),447 (str(pathlib.Path("example/__main__.py")), "example", "python -m example"),448 (str(pathlib.Path("example/cli.py")), "example", "python -m example.cli"),449 (str(pathlib.Path("./example")), "", "example"),450 ],451)452def test_detect_program_name(path, main, expected):453 assert click.utils._detect_program_name(path, _main=MockMain(main)) == expected
48 unmodified lines
modified:CHANGES.rst+1 added
13 unmodified lines
14- Bash version detection doesn't fail on Windows. :issue:`2461`15- Completion works if there is a dot (``.``) in the program name. :issue:`2166`16- Improve type annotations for pyright type checker. :issue:`2268`17- Improve responsiveness of ``click.clear()``. :issue:`2284`18- Improve command name detection when using Shiv or PEX. :issue:`2332`192021Version 8.1.322-------------
1040 unmodified lines