mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #1595 from Celeborn2BeAlive/1583-wrong-shebang-line-win10-pyenvwin
Drop python.exe extension on windows in shebang line to fix pyenv-win setup
This commit is contained in:
commit
8f32c5b929
2 changed files with 7 additions and 2 deletions
|
|
@ -55,7 +55,7 @@ def is_our_script(filename: str) -> bool:
|
||||||
|
|
||||||
def shebang() -> str:
|
def shebang() -> str:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
py = SYS_EXE
|
py, _ = os.path.splitext(SYS_EXE)
|
||||||
else:
|
else:
|
||||||
exe_choices = [
|
exe_choices = [
|
||||||
f'python{sys.version_info[0]}.{sys.version_info[1]}',
|
f'python{sys.version_info[0]}.{sys.version_info[1]}',
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,13 @@ def patch_sys_exe(exe):
|
||||||
|
|
||||||
|
|
||||||
def test_shebang_windows():
|
def test_shebang_windows():
|
||||||
|
with patch_platform('win32'), patch_sys_exe('python'):
|
||||||
|
assert shebang() == '#!/usr/bin/env python'
|
||||||
|
|
||||||
|
|
||||||
|
def test_shebang_windows_drop_ext():
|
||||||
with patch_platform('win32'), patch_sys_exe('python.exe'):
|
with patch_platform('win32'), patch_sys_exe('python.exe'):
|
||||||
assert shebang() == '#!/usr/bin/env python.exe'
|
assert shebang() == '#!/usr/bin/env python'
|
||||||
|
|
||||||
|
|
||||||
def test_shebang_posix_not_on_path():
|
def test_shebang_posix_not_on_path():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue