Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
link PyQt components into new virtualenv after creation (`postmkvirtualenv`)
#!/usr/bin/env bash
# This hook is run after a new virtualenv is activated.
#set -e # abort after any errors
#set -u # exit after accessing an undefined variable
libs=(PyQt4 sip.so sipconfig.py)
python_version=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
var=( $(which -a ${python_version}) )
if [ ${#var[@]} -lt 2 ]; then
echo "could not find system install of ${python_version}: unable to link PyQt components" >&2
else
get_python_lib_cmd="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
lib_virtualenv_path=$(${var[0]} -c "${get_python_lib_cmd}")
lib_system_path=$(${var[-1]} -c "${get_python_lib_cmd}")
for lib in ${libs[@]}
do
if [ ! -e "${lib_virtualenv_path}/${lib}" ]; then
ln -s "${lib_system_path}/${lib}" "${lib_virtualenv_path}/${lib}"
fi
done
fi
@Midnighter

This comment has been minimized.

Copy link
Owner Author

Midnighter commented Jan 11, 2015

I avoid set -e and set -u myself here because I work in tmux and exiting the script will close my window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.