On Wed, Dec 14, 2011 at 09:50:46PM +0100, Giovanni Campagna wrote:
Hello everyone,
as you may know, I'd like to start working to extend PackageDB to export
its applications database so that it can be used by local application
installers.
The first step, of course, is getting a local instance of pkgdb running
on my machine.
Using the method described in README, I get a VersionConflict, because
CherryPy 3.2 is installed. I installed also CherryPy 2.3.0
(python-cherrypy2), but apparently paven cannot find it. Also, trying to
remove python-cherrypy will also remove TurboGears. I'm on Fedora 16,
with full updates, and I'm building from the devel bzr branch.
I'm not used to setuptools and python egg packages, so it could be that
I'm doing something wrong. I would be glad if you could point me to the
right direction.
Yeah, you've rightly assigned blame to setuptools here. What's happening
is
that TurboGears1 uses an old version of cherrypy. We have packaged this
using setuptools multiple versioning. But setuptools doesn't really have
a method of specifying a default version when doing this. That's the source
of the error.
In order to work around it there are several recipes.
The most production quality is to put code like the following as close to
the very top of the script that is originally run as possible::
import __main__
if hasattr('__requires__', __main__):
if isinstance(__main__.__requires__, basestring):
__main__.__requires__ = [__main__.__requires__]
else:
__main__.__requires__ = list(__main__.__requires__)
else:
__main__.__requires__ = []
__main__.__requires__.append('TurboGears[sqlalchemy]')
import pkg_resources
This will work as long as we do this before pkg_resources is imported for
the first time. If pkg_resources has already been imported then it's too
late. You'll need to get this block of code to execute sooner.
Another way that works fine in testing but isn't as portable in production
is to specify the path to the proper cherrypy module. On Fedora16 this
should look like:
$ export PYTHONPATH='/usr/lib/python2.7/site-packages/CherryPy-2.3.0-py2.7.egg
$ paver egg_info
-Toshio