I have post-receive hook with install command:
pip install -r requirements.txt
After I call git push live master hook calls pip install command but on remote server installing started on system python2.7 instead of python3.6.4 which I specified as global in pyenv. I guess .bashrc with pyenv setup is not called in non-interactive sessions...
so... how to specify python interpreter in git post-receive hook?
Ugly solutions:
/usr/bin/python so it points to needed interpreter (and same for pip)/home/user/.pyenv/.../pip install -r ...Solved by creating separate virtualenv and adding source path/to/virtualenv/activate to the hook script.
In my case virtualenv created by pyenv had non-executable activate so also needed to make it executable with chmod +x path/to/activate
By copying the lines that make pyenv work right into the post-receive hook script before using Python the first time, pyenv can be used as expected.
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With