virtualenv that can find relocated libraires (like mysqlclient lib for MySQLdb)

前端 未结 2 1407
日久生厌
日久生厌 2021-01-05 01:32

I would like to be able to share a virtualenv that is self contained, i.e. insure that all scripts installed are able to run directly without needing to set anything. E.g. I

2条回答
  •  囚心锁ツ
    2021-01-05 02:21

    This is maybe not the best solution, but you can hack the virtualenv active script to set some environment variable (this is a script that we will need to use anyway). In the installation script of the virtualenv, I added:

    echo 'export LD_LIBRARY_PATH=/path/to/lib:$LD_LIBRARY_PATH' >> /path/to/virtualenv/activate
    

    Now every time someone uses my virtualenv, it also includes the LD_LIBRARY_PATH to find the mysql libraries.

    Drawbacks I can see:

    • Don't work nicely with virtualenv's deactivate

    • Won't help if you want to distribute your package with the standard distutils setup.py.

提交回复
热议问题