views:

148

answers:

3

I'm trying to get a package installed on Google App Engine. The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine.

There's no platform-specific code in the source, however, so it's no problem to just zip up the source and include those in the system path. And I've gotten a version of pkg_resources installed and working as well.

The only problem is getting the package actually registered with pkg_resources so when it calls iter_entry_points it can find the appropriate plugins.

What methods do I need to call to register modules on sys.path with all the appropriate metadata, and how do I figure out what that metadata needs to be?

+1  A: 

Yes, for setuptools-based libraries you'll need to deploy the library's "Egg" metadata along with it. The easiest way I've found is to deploy a whole virtualenv environment containing your project and the required libraries.

I did this process manually and added this code to main.py to initialize the site-packages folder in a way that pkg_resources will work:

import site
site.addsitedir('lib/python2.5/site-packages')

However, you could try appengine-monkey which automates most of this for you.

Matt Good
A: 

On your local development system, run python setup.py bdist_egg, which will create a Zip archive with the necessary metadata included. Add it to your sys.path, and it should work properly.

John Millikin
A: 

Create a setup.py for the package just as you would normally, and then use "setup.py sdist --formats=zip" to build your source zip. The built source zip will include an .egg-info metadata directory, which will then be findable by pkg_resources. Alternately, you can use bdist_egg for all your packages.

pjeby