SQLAlchemy 0.6 has this nice optimization for using c extensions for
performance.  It almost seems it should be enabled by default, but is
not (probably since it isn't pure python).

To install with c extensions, you need to pass "--with-cextensions" to
the setup.py of SQLAlchemy.  I imagined that certainly setuptools has
a way to accomplish this, even if SQLAlchemy is being installed as a
dependency of the turbogears project.

Apparently not! (Or at least my research found no mechanism for this).

I invented this work-around, (not pretty, by necessity).  If there is
a better way (wouldn't surprise me), I'd love to see it, but this
works:

In your turbogears application project's setup.py, you can accomplish
passing the "--with-cextensions" to SQLAlchemy's setup.py as follows:

===================================================
# -*- coding: utf-8 -*-
try:
    from setuptools import setup, find_packages
except ImportError:
    from ez_setup import use_setuptools
    use_setuptools()
    from setuptools import setup, find_packages

#kb: since apparently setuptools has no mechanism to pass
# arguments to the dependencies, I am "decorating" the function
# that runs the command and adding the arguments myself...
from setuptools.command.easy_install import easy_install
normal_run_setup_fn = easy_install.run_setup
def setup_hook(self, setup_script, setup_base, args):
    # SQLAlchemy we want to run setup.py with
    if setup_script.find('/SQLAlchemy') > -1 and
setup_script.endswith('setup.py'):
        args.insert(0,'--with-cextensions')
    normal_run_setup_fn(self, setup_script, setup_base, args)
easy_install.run_setup = setup_hook


setup(
    name='yourtgapp',
    version='0.1',
    description='',
    author='',
    author_email='',
    install_requires=[
        "SQLAlchemy >= 0.6",
        "tg.devtools >= 2.0.1",
......
=======================================================

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to