From: Mike Bayer Date: Fri, 5 Mar 2010 15:33:21 +0000 (+0000) Subject: use a flag to build cextensions (thanks again to Genshi for the tip) X-Git-Tag: rel_0_6beta2~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6caca941c89c5b7967a8d43d486704d586a6971;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git use a flag to build cextensions (thanks again to Genshi for the tip) --- diff --git a/README b/README index 4bbdd20a11..ad618ad39f 100644 --- a/README +++ b/README @@ -38,11 +38,13 @@ path. Installing the C extension -------------------------- -Edit "setup.py" and set ``BUILD_CEXTENSIONS`` to ``True``, then install it as -above. If you want only to build the extension and not install it, you can do -so with:: +If installing with Setuptools or Distribute, the C extensions are built +and installed using the --with-cextensions flag: - python setup.py build + python setup.py --with-cextensions install + +If using plain Distutils, change the BUILD_CEXTENSIONS flag in setup.py +to "True". Running Tests ------------- diff --git a/setup.py b/setup.py index 37fc606f2f..dd75c6fc65 100644 --- a/setup.py +++ b/setup.py @@ -4,8 +4,9 @@ Please see README for basic installation instructions. """ -# set this flag to True to compile -# C extensions +# If using distutils (not distribute/setuptools), +# set this flag to True to compile C extensions. +# Otherwise use --with-cextensions BUILD_CEXTENSIONS = False import os @@ -25,10 +26,33 @@ if sys.version_info >= (3, 0): ) try: - from setuptools import setup, Extension + from setuptools import setup, Extension, Feature except ImportError: from distutils.core import setup, Extension + Feature = None +if Feature: + extra.update( + features = {'cextensions' : Feature( + "optional C speed-enhancements", + standard = False, + ext_modules = [ + Extension('sqlalchemy.cprocessors', + sources=['lib/sqlalchemy/cextension/processors.c']), + Extension('sqlalchemy.cresultproxy', + sources=['lib/sqlalchemy/cextension/resultproxy.c']) + ], + )} + ) +elif BUILD_CEXTENSIONS: + extra.update( + ext_modules = [ + Extension('sqlalchemy.cprocessors', + sources=['lib/sqlalchemy/cextension/processors.c']), + Extension('sqlalchemy.cresultproxy', + sources=['lib/sqlalchemy/cextension/resultproxy.c']) + ] + ) def find_packages(dir_): packages = [] @@ -45,7 +69,6 @@ v = open(os.path.join(os.path.dirname(__file__), 'lib', 'sqlalchemy', '__init__. VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v.read()).group(1) v.close() - setup(name = "SQLAlchemy", version = VERSION, description = "Database Abstraction Library", @@ -57,12 +80,6 @@ setup(name = "SQLAlchemy", license = "MIT License", tests_require = ['nose >= 0.11'], test_suite = "nose.collector", - ext_modules = (BUILD_CEXTENSIONS and - [Extension('sqlalchemy.cprocessors', - sources=['lib/sqlalchemy/cextension/processors.c']), - Extension('sqlalchemy.cresultproxy', - sources=['lib/sqlalchemy/cextension/resultproxy.c']) - ]), entry_points = { 'nose.plugins.0.10': [ 'sqlalchemy = sqlalchemy.test.noseplugin:NoseSQLAlchemy',