Skip to content

Commit 91fb22b

Browse files
committed
run .py hooks with same interpreter
Avoids #! and allows .py hook scripts to work on windows
1 parent 93062ba commit 91fb22b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cue.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,15 +605,21 @@ def add_dependency(dep):
605605
if dep + '_HOOK' in setup:
606606
hook = setup[dep + '_HOOK']
607607
hook_file = os.path.join(curdir, hook)
608+
hook_ext = os.path.splitext(hook_file)[1]
608609
if os.path.exists(hook_file):
609-
if re.match(r'.+\.patch$', hook):
610+
if hook_ext == '.patch':
610611
apply_patch(hook_file, cwd=place)
611-
elif re.match(r'.+\.(zip|7z)$', hook):
612+
elif hook_ext in ('.zip', '.7z'):
612613
extract_archive(hook_file, cwd=place)
614+
elif hook_ext == '.py':
615+
print('Running py hook {0} in {1}'.format(hook, place))
616+
sp.check_call([sys.executable, hook_file], cwd=place)
613617
else:
614618
print('Running hook {0} in {1}'.format(hook, place))
615619
sys.stdout.flush()
616620
sp.check_call(hook_file, shell=True, cwd=place)
621+
else:
622+
print('Skipping invalid hook {0} in {1}'.format(hook, place))
617623

618624
# write checked out commit hash to marker file
619625
head = get_git_hash(place)

0 commit comments

Comments
 (0)