[CentralOH] How do .eggs work in search paths?

William McVey wam at cisco.com
Wed Dec 5 18:39:03 CET 2012

On Tue, 2012-12-04 at 22:08 -0500, Joshua Kramer wrote:
> The eggs are really directories themselves, and under each .egg lies
> the module.  So for example, under Mezzanine-1.2.4-py2.6.egg, there's
> a 'mezzanine' directory.
> In the wsgi launcher, I have a call like this:
> sys.path.append('/srv/website/www/site-packages')

Eggs, both the zipped up versions as well as unzipped directory versions
are containers for packages, more akin to directories than python
packages or modules. Setuptools adds .egg files/directories to your
sys.path directly (typically using something like an easy-install.pth
> This appears to not be working, as Apache can't find any of the
> modules under that site-packages directory that are within the eggs.

Right, because your sys.path doesn't list a directory full of packages,
it lists a directory full of eggs (e.g. directories). 
> Is there a cleaner or more elegant way to get to where I want to be?

Yup. You *really* want to be using virtualenv. Apache's mod_wsgi
supports virtualenvs
(http://code.google.com/p/modwsgi/wiki/VirtualEnvironments). Lacking
that, you might want to try using .pth files in your system path to
augment your search list (see the docs for 'site' module for details
on .pth files) to include the paths to your .eggs. Still, the virtualenv
is a much cleaner (and altogether more supportable) solution.

  -- William

More information about the CentralOH mailing list