Is it possible to add PyQt4/PySide packages on a Virtualenv sandbox?

后端 未结 13 1980
失恋的感觉
失恋的感觉 2020-11-28 20:16

I\'m using Virtualenv with profit on my development environment with web.py, simplejson and other web oriented packages.
I\'m going to develop

13条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 20:29

    I have the same problem. I use virtualenvwrapper, so I wrote this script to create a link to PyQt in every new virtual environment. Maybe is useful for someone else:

    #!/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
    

    link to gist

提交回复
热议问题