Avoid extra interpreter startup in hook

This commit is contained in:
Kovid Goyal
2025-09-21 12:23:32 +05:30
parent 8d8580973d
commit 461ec48174
3 changed files with 22 additions and 6 deletions
+8 -3
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
import runpy
import subprocess
import sys
@@ -37,11 +38,15 @@ filenames = tuple(filter(testfile, output))
if not filenames:
sys.exit(0)
check_args = [sys.executable, './setup.py', 'check', '--no-editor']
check_args = ['./setup.py', 'check', '--no-editor']
# let's hope that too many arguments do not hold any surprises
for f in filenames:
check_args.append('-f')
check_args.append(f)
returncode = subprocess.call(check_args)
sys.exit(returncode)
before = sys.argv
try:
sys.argv = check_args
runpy.run_path('setup.py', run_name='__main__')
finally:
sys.argv = before