Version 1 (modified by spascoe, 13 years ago) (diff)


When deploying services as eggs we have found we often want to configure which eggs are visible to a python process. Sometimes different services running on the same machine require different versions of an egg. An elegant way to manage this is to not install a project's eggs with {{{easy_install}} at all but to use a plugin directory instead.

For instance, say you have a pylons application that needs ows-common 0.1.1dev-r3812. This is a very raw version of ows-common so we don't even want to install it in multi-version mode with easy_install -m. Instead we put the egg in a subdirectory of the pylons app's deployment directory.

 + app_deployment
 \-+ eggs
 | |
 | \ ows_common-0.1.1dev_r3812-py2.5.egg
 \ development.ini

Provided ows_common is not installed system-wide (or is installed in multi-version mode) the following script will load the any eggs in the app_deployment/eggs directory before running paster:

from pkg_resources import *
dists, errors = working_set.find_plugins(Environment(['./eggs']))

for dist in dists:
    print 'Adding %s to working_set' % dist
if errors:
    print "WARNING: Couldn't load", errors

load_entry_point('PasteScript', 'console_scripts', 'paster')()

See  DCIP Trac changeset:974 for an example of using this on the DDP WMS.

In the future we hope to have a command-line tool for doing this sort of thing.