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