diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -117,6 +117,15 @@ use_htsts = false ## number of commits stats will parse on each iteration commit_parse_limit = 25 +## Path to Python executable to be used for git hooks. +## This value will be written inside the git hook scripts as the text +## after '#!' (shebang). When empty or not defined, the value of +## 'sys.executable' at the time of installation of the git hooks is +## used, which is correct in many cases but for example not when using uwsgi. +## If you change this setting, you should reinstall the Git hooks via +## Admin > Settings > Remap and Rescan. +# git_hook_interpreter = /srv/kallithea/venv/bin/python2 + ## path to git executable git_path = git diff --git a/kallithea/lib/paster_commands/template.ini.mako b/kallithea/lib/paster_commands/template.ini.mako --- a/kallithea/lib/paster_commands/template.ini.mako +++ b/kallithea/lib/paster_commands/template.ini.mako @@ -211,6 +211,18 @@ use_htsts = false <%text>## number of commits stats will parse on each iteration commit_parse_limit = 25 +<%text>## Path to Python executable to be used for git hooks. +<%text>## This value will be written inside the git hook scripts as the text +<%text>## after '#!' (shebang). When empty or not defined, the value of +<%text>## 'sys.executable' at the time of installation of the git hooks is +<%text>## used, which is correct in many cases but for example not when using uwsgi. +<%text>## If you change this setting, you should reinstall the Git hooks via +<%text>## Admin > Settings > Remap and Rescan. +# git_hook_interpreter = /srv/kallithea/venv/bin/python2 +%if git_hook_interpreter: +git_hook_interpreter = ${git_hook_interpreter} +%endif + <%text>## path to git executable git_path = git diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py --- a/kallithea/model/scm.py +++ b/kallithea/model/scm.py @@ -727,8 +727,11 @@ class ScmModel(object): Git hook scripts so they invoke Kallithea code with the right Python interpreter and in the right environment. """ + # Note: sys.executable might not point at a usable Python interpreter. For + # example, when using uwsgi, it will point at the uwsgi program itself. # FIXME This may not work on Windows and may need a shell wrapper script. - return (sys.executable + return (kallithea.CONFIG.get('git_hook_interpreter') + or sys.executable or '/usr/bin/env python2') def install_git_hooks(self, repo, force_create=False):