mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:27:14 +00:00
[script] Make pre-commit and helpers work on Windows (#16260)
Co-authored-by: Jonathan Swoboda <swoboda1337@users.noreply.github.com>
This commit is contained in:
@@ -55,7 +55,7 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
name: pylint
|
name: pylint
|
||||||
entry: python3 script/run-in-env.py pylint
|
entry: python script/run-in-env.py pylint
|
||||||
language: system
|
language: system
|
||||||
types: [python]
|
types: [python]
|
||||||
files: ^esphome/.+\.py$
|
files: ^esphome/.+\.py$
|
||||||
@@ -68,5 +68,5 @@ repos:
|
|||||||
additional_dependencies: []
|
additional_dependencies: []
|
||||||
- id: ci-custom
|
- id: ci-custom
|
||||||
name: ci-custom
|
name: ci-custom
|
||||||
entry: python3 script/run-in-env.py script/ci-custom.py
|
entry: python script/run-in-env.py script/ci-custom.py
|
||||||
language: system
|
language: system
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ def lint_ext_check(fname):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
def lint_executable_bit(fname: Path) -> str | None:
|
def lint_executable_bit(fname: Path) -> str | None:
|
||||||
ex = EXECUTABLE_BIT[str(fname)]
|
ex = EXECUTABLE_BIT[fname.as_posix()]
|
||||||
if ex != 100644:
|
if ex != 100644:
|
||||||
return (
|
return (
|
||||||
f"File has invalid executable bit {ex}. If running from a windows machine please "
|
f"File has invalid executable bit {ex}. If running from a windows machine please "
|
||||||
|
|||||||
@@ -44,7 +44,14 @@ def find_and_activate_virtualenv():
|
|||||||
def run_command():
|
def run_command():
|
||||||
# Execute the remaining arguments in the new environment
|
# Execute the remaining arguments in the new environment
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
result = subprocess.run(sys.argv[1:], check=False, close_fds=False)
|
args = sys.argv[1:]
|
||||||
|
# Windows CreateProcess doesn't follow shebangs, so prepend the
|
||||||
|
# current interpreter when the entry is a .py script. Using
|
||||||
|
# sys.executable also pins the nested call to the same Python that
|
||||||
|
# ran us — no ambiguous PATH lookup for "python".
|
||||||
|
if args[0].endswith(".py"):
|
||||||
|
args = [sys.executable, *args]
|
||||||
|
result = subprocess.run(args, check=False, close_fds=False)
|
||||||
sys.exit(result.returncode)
|
sys.exit(result.returncode)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
|
|||||||
Reference in New Issue
Block a user