Skip to content

Instantly share code, notes, and snippets.

@tsileo
Forked from jlesquembre/postmkvirtualenv
Created July 6, 2012 11:56
Show Gist options
  • Save tsileo/3059737 to your computer and use it in GitHub Desktop.
Save tsileo/3059737 to your computer and use it in GitHub Desktop.
Creates a symlink to PyQt libraries when a new virtual environment is created
#!/bin/bash
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
LIBS=( PyQt4 sip.so )
PYTHON_VERSION=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
VAR=( $(which -a $PYTHON_VERSION) )
GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD")
LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD")
for LIB in ${LIBS[@]}
do
ln -s $LIB_SYSTEM_PATH/$LIB $LIB_VIRTUALENV_PATH/$LIB
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment