distutils and decorators

Robert Brewer fumanchu at amor.org
Wed Sep 21 11:04:06 EDT 2005


We're trying to get CherryPy 2.1 RC 1 out the door, but setup.py is
giving us some problems. In our test suite, we want to test a decorator
that we provide. Of course, decorators won't work in Python 2.3, so I
put the actual decorated functions into a separate module, and import it
into the test suite only when running Python 2.4:

    if sys.hexversion > 0x020400A2:
        from cp_decorator_tests import Exposing, ExposingNewStyle

Now "setup.py install" is complaining when run under Python 2.3, since
it tries to byte-compile every .py file. Output from a second install
run:

C:\Python23\Lib\site-packages\cptrunk>python setup.py install
running install
running build
running build_py
running install_lib
byte-compiling
C:\Python23\Lib\site-packages\cherrypy\test\cp_decorator_tests.py to
cp_decorator_tests.pyc
  File
"C:\Python23\Lib\site-packages\cherrypy\test\cp_decorator_tests.py",
line 4
    @cherrypy.expose("1")
    ^
SyntaxError: invalid syntax
running install_data


1. Is there some way to tell setup to skip the byte-compiling on that
single file, or

2. Is there some way to only ship cp_decorator_tests.py if you're
running 2.4, or

3. Is there some better way to optionally test decorators, like using
eval, or

4. other...?


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list