Make some modules from global site packages available in virtualenv

I want to use virtualenv by default (without site packages).

But some modules are hard to install in virtualenv (e.g. gtk). With β€œhard”, I mean that you have to have a lot of c-header files and you need to collect a lot of material.

I know that I can solve this without installing these packages using pip, but create symbolic links to make some modules accessible from the global site packages directory.

But is this the right direction?

Is there a way to create symbolic links using pip or virtualenv?

Update

In 2013, I needed modules like psycopg2, gtk, python-ldap and others that are installed on my Linux server via rpm / dpkg in virtualenv.

Simling or other workarounds made things more complicated, not simpler. We use this option today (2017)

- system-site-packages

Give your virtual environment access to global site packages.

+6
source share
2 answers

I would say yes, this is the right direction.

Your questions sound similar to what I had in mind: installing OpenCV in virtualenv. My problem was that OpenCV was not accessible via pip (Python package index). What I ended up with was a request to a system-wide global Python installation for the module in question, and then copying .so to my virtualenv.

The whole process, including the Makefile template that I used, is captured here: fooobar.com/questions/773930 / ...

You can do something similar with sym-linking instead of copying. The reason I finished copying the library was because I use Make, and Make does not handle dependencies for symbolic links in the way I need (as explained in the above URL.)

Hope this helps ...

0
source

How do you compile each of these hard packages from scratch? You are doing something like:

python setup.py install 

If so, replace it with:

 python setup.py bdist_wheel 

Then look in the ./dist directory for the .whl file. Then take everything that is and do it (after activating the environment)

 pip install `./dist/whateverTheFileIsCalled.whl` 
0
source

Source: https://habr.com/ru/post/955416/


All Articles