Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I deal with python eggs for multiple platforms in one location?

We have a common python installation for all of our systems in order to ensure every system has the same python installation and to ease configuration issues. This installation is located on a shared drive. We also have multiple platforms that share this installation. We get around conflicting platform-specific files by setting the --exec-prefix configure option when compiling python.

My issue is that I now want to install an egg using easy_install (or otherwise) that is platform-dependent. easy_install puts the egg in the site-packages directory of the platform-independent part of the install. The name of the egg has the platform in it so there should be no conflict. But python will only load the first one it finds. (So, on Solaris it might try to load the Linux egg). Modifying the easy-install.pth file can change which one it finds, but that's pretty useless.

I can move the .egg files into a platform-depended packages directory and then use pkg_resources.require() to load them (or manually adjust the path). But it seems as though I shouldn't have to since the platform is in the name of the egg.

Is there any more generic way I can ensure that python will load the egg for the correct platform?

like image 405
Philbert Avatar asked Dec 14 '09 21:12

Philbert


2 Answers

Try virtualenv ... http://pypi.python.org/pypi/virtualenv ... helps you create isolated environment with it's own python interpreter + site_packages folder. Thus you never have any conflicts with packages installed in say local path.

like image 104
Ankur Gupta Avatar answered Oct 20 '22 01:10

Ankur Gupta


What I ended up going with was manually moving the platform-dependent egg to the platform-specific site-packages directory (as specified at http://docs.python.org/install/index.html). Then I made another easy-install.pth in that same directory, listing the eggs to be installed.

This would be much more convenient if easy_install were to honour the exec_prefix and put platform-dependent eggs in the correct "non-pure module distribution" location. Perhaps I will request this from the easy_install folks.

like image 36
Philbert Avatar answered Oct 19 '22 23:10

Philbert