summaryrefslogtreecommitdiff
path: root/pkg/postmkvenv.sh
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-11 13:58:47 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-11 13:58:47 -0300
commit99e644bf4d941dfa430d21dba9ac99f138f5f7cc (patch)
tree2f29f73468714a9c27b954a16296a39ba1172441 /pkg/postmkvenv.sh
parenteaec4a9fff67134284f45eb850f0d7e0f7f275f0 (diff)
Add postmkvenv script with PySide
Diffstat (limited to 'pkg/postmkvenv.sh')
-rwxr-xr-xpkg/postmkvenv.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/postmkvenv.sh b/pkg/postmkvenv.sh
new file mode 100755
index 00000000..2f0cba45
--- /dev/null
+++ b/pkg/postmkvenv.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# This hook is run after a new virtualenv is activated.
+# ~/.virtualenvs/postmkvirtualenv
+# tested and working in debian
+
+# Symlinks PyQt4 from global installation into virtualenv site-packages
+# XXX TODO:
+# script fails in ubuntu, with path: /usr/lib/pymodules/python2.7/PyQt4
+# use import PyQt4; PyQt4.__path__ instead
+
+platform='unknown'
+unamestr=$(uname)
+if [[ "$unamestr" == 'Linux' ]]; then
+ platform='linux'
+elif [[ "$unamestr" == 'Darwin' ]]; then
+ platform='darwin'
+fi
+
+LIBS=( PySide )
+
+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")
+
+if [[ $platform == 'linux' ]]; then
+ LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD")
+elif [[ $platform == 'darwin' ]]; then
+ LIB_SYSTEM_PATH=$(/opt/local/bin/python2.6 -c "$GET_PYTHON_LIB_CMD")
+else
+ echo "unsupported platform; not doing symlinks"
+fi
+
+for LIB in ${LIBS[@]}
+do
+ if [[ ! -e $LIB_VIRTUALENV_PATH/$LIB ]]; then
+ ln -s $LIB_SYSTEM_PATH/$LIB $LIB_VIRTUALENV_PATH/$LIB
+ fi
+done