58c14e2
============
58c14e2
CherryPy 2.x
58c14e2
============
58c14e2
58c14e2
CherryPy 2.x for Fedora is being provided so that apps written for
58c14e2
TurboGears 1.x can continue to run.  It relies on eggs to enable multiple
58c14e2
versions to be installed.
58c14e2
58c14e2
If you are using CherryPy via TurboGears, everything should work out of the
58c14e2
box for new projects quickstarted with the Fedora 8 packages.  Existing projects
58c14e2
will need a small adjustment to run correctly.  In your project's start-APP.py
58c14e2
script you need to change the commands that import TurboGears from this::
58c14e2
58c14e2
  import pkg_resources
58c14e2
  pkg_resources.require('TurboGears')
58c14e2
58c14e2
to this::
58c14e2
58c14e2
  __requires__ = 'TurboGears'
58c14e2
  import pkg_resources
58c14e2
58c14e2
with the packages provided by Fedora 8+.
58c14e2
58c14e2
If you are using CherryPY via your own code and absolutely must use the 2.x
58c14e2
version rather than 3.x, you will need to do one of the following to make it
58c14e2
work in your code:
58c14e2
58c14e2
1) Manually change your python path to place the egg directory before
58c14e2
   site-packages.  Note that if you do it this way you will either have to
58c14e2
   change your code whenever a new version comes out (for instance, if a
f7d60e2
   bugfix release, CherryPy-2.3.1, is released.)  The code would look
58c14e2
   something like this::
58c14e2
f7d60e2
     import sys, os
f7d60e2
     from distutils.sysconfig import get_python_lib
58c14e2
     compatCherryPyPath = os.path.join(
f7d60e2
            get_python_lib(), 'CherryPy-2.3.0-py2.5.egg')
58c14e2
     sys.path.insert(0, compatCherryPyPath)
58c14e2
     import cherrypy
58c14e2
58c14e2
2) Use setuptools and entrypoints. To do this you have a function in a python
58c14e2
   module that is your main function.  You define this as an entry point in
58c14e2
   setup.py.  For instance, if you wanted your script to be called
58c14e2
   "nifty-foo" and the entry point was the main() function in the module
58c14e2
   nifty.foo, you would use this in setup.py::
58c14e2
58c14e2
     # List the versions of CherryPy that will work
58c14e2
     install_requires = [
58c14e2
        'CherryPy >= 2.2,<3.0alpha'
58c14e2
        ]
58c14e2
     # Add the information necessary to create the script that requires
58c14e2
     # the CherryPy version
58c14e2
     setup (
58c14e2
        name='Nifty',
58c14e2
        version='1.0',
58c14e2
        entry_points = '''
58c14e2
          [console_scripts]
58c14e2
          nifty-foo = nifty.foo:main
58c14e2
        ''',
58c14e2
     [...]
58c14e2
58c14e2
   When you use setup.py to install this script it will create a script that
58c14e2
   looks like this::
f7d60e2
58c14e2
      #!/usr/bin/python
58c14e2
      __requires__ = 'Nifty==1.0'
58c14e2
      import sys
58c14e2
      from pkg_resources import load_entry_point
58c14e2
58c14e2
      sys.exit(
58c14e2
        load_entry_point('Nifty==1.0', 'console_scripts', 'nifty-foo')()
58c14e2
      )
58c14e2
58c14e2
   The script in turn, references the egg metadata for your module which
58c14e2
   lists the dependency from Nifty to CherryPy>=2.2, < 3.0alpha.
58c14e2
58c14e2
Note that although there may be other methods of making this work in some
58c14e2
circumstances, these are the only methods that the setuptools author and
58c14e2
we are able to say will work in all circumstances in this environment.  Other
58c14e2
methods may not work reliably in some versions of setuptools.
f7d60e2
f7d60e2
In particular, if you have both the python-cherrypy (at version 3.x) and
f7d60e2
python-cherrypy2 packages installed, this will not work::
f7d60e2
f7d60e2
  from pkg_resources import require
f7d60e2
  require("CherryPy>=2.3,<3.0alpha")
f7d60e2
  import cherrypy
f7d60e2
  print cherrypy.__version__