Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Creates a symlink to PyQt libraries when a new virtual environment is created

View postmkvirtualenv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/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

Under Ubuntu (13.10), this links to /usr/lib/python3.3/site-packages/sip.so and /usr/lib/python3.3/site-packages/PyQt4, which are non-existent. These files are living in /usr/lib/python3/dist-packages/
This is because Debian/Ubuntu installs Python packages into dist-packages, not site-packages.
So the script is not usable under *buntu/Debian

bootchk commented

Yes, but it is useable if you build PyQt yourself, since it installs to site-packages. But then, python3 on Ubuntu/Debian does not seem to have site-packages in its PYTHONPATH.

So is there a general problem, that Debian has broken a Python convention that the default PYTHONPATH includes site-packages? Is that the mess that virtualenv is designed to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.