Virtualenv for multiple users or groups

I am creating a new system for a group of Python newbies to do some scientific work using Python. It had two different pythons (32 and 64 bits), and I want to install a set of common modules that users will use on the system.

  • (a) Some modules work out of the box for both pythons,
  • (b) some compilation code and set differently depending on python and
  • (c) some do not work at all on certain pythons.

I was told that virtualenv (+ wrapper) is good for this type of situation, but I don’t understand this.

  • Can I use virtualenv to configure isolated modules on multiple accounts without installing each module for each user?
  • Can I use virtualenv to save time on case (a), i.e. install a module, but all pythons see it?

I like the idea of ​​isolating environments and then simply typing "workon science32", "workon science64", depending on problems with case (c).

Any advice is appreciated.

+4
source share
1 answer

With virtualenv, you can allow each environment to use globally installed system packages by simply disabling the --no-site-packages option. This is the default behavior.

If you want each environment to install all its own packages, use --no-site-packages and you will get a simple python installation to install your own modules. This is useful if you do not want packages to conflict with system packages. I usually do this only so that changes in the system do not interfere with the working code.

I would be careful to think of it as sandboxes, because they are only partially isolated. The paths to the python binaries and libraries are changed to use the environment, but in fact that's all that happens. Virtualenv does nothing to prevent code from running from destructive things into the system. The best way for the sandbox is to correctly set Linux / Unix permissions and provide them with their own user accounts.

EDIT for version 1.7 +

By default, 1.7 should not include system packages, so if you want to use system packages, use the --system-site-packages option. For more information, check out the docs .

+3
source

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


All Articles