From cd7e8891bd052e9de61ac08c50f6dc0f01e47eff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 10 Jun 2018 07:29:04 +0530 Subject: [PATCH] Fix python invocation in git hooks --- setup/git_post_checkout_hook.py | 7 +++++-- setup/git_post_rewrite_hook.py | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/setup/git_post_checkout_hook.py b/setup/git_post_checkout_hook.py index 1d4b7213cb..24e393ed9b 100755 --- a/setup/git_post_checkout_hook.py +++ b/setup/git_post_checkout_hook.py @@ -9,15 +9,19 @@ __copyright__ = '2013, Kovid Goyal ' import os, subprocess, sys prev_rev, current_rev, flags = [x.decode('utf-8') if isinstance(x, bytes) else x for x in sys.argv[1:]] + + def get_branch_name(rev): return subprocess.check_output(['git', 'name-rev', '--name-only', rev]).decode('utf-8').strip() + + base = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) os.chdir(base) if flags == '1': # A branch checkout prev_branch, cur_branch = map(get_branch_name, (prev_rev, current_rev)) - subprocess.check_call(['python', 'setup.py', 'gui', '--summary']) + subprocess.check_call([sys.executable, 'setup.py', 'gui', '--summary']) # Remove .pyc files as some of them might have been orphaned for dirpath, dirnames, filenames in os.walk('.'): @@ -25,4 +29,3 @@ if flags == '1': # A branch checkout fpath = os.path.join(dirpath, f) if f.endswith('.pyc'): os.remove(fpath) - diff --git a/setup/git_post_rewrite_hook.py b/setup/git_post_rewrite_hook.py index a28f2a62b9..c989a70032 100755 --- a/setup/git_post_rewrite_hook.py +++ b/setup/git_post_rewrite_hook.py @@ -14,6 +14,4 @@ os.chdir(base) action = [x.decode('utf-8') if isinstance(x, bytes) else x for x in sys.argv[1:]][0] if action == 'rebase': - subprocess.check_call(['python', 'setup.py', 'gui']) - - + subprocess.check_call([sys.executable, 'setup.py', 'gui'])