From: Stefan Behnel Date: Sun, 8 Jun 2008 12:56:56 +0000 (+0200) Subject: compile Cython.Plex.Scanners module on install to speed up compilation X-Git-Tag: 0.9.8rc1~11^2~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=911b8034ab22ee52272b8e67c84920007db89060;p=cython.git compile Cython.Plex.Scanners module on install to speed up compilation --- diff --git a/setup.py b/setup.py index ad65a14a..1d6cb486 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ -from distutils.core import setup +from distutils.core import setup, Extension from distutils.sysconfig import get_python_lib -import os, sys +import os, os.path import sys from Cython.Compiler.Version import version @@ -22,6 +22,31 @@ if os.name == "posix": else: scripts = ["cython.py"] +try: + sys.argv.remove("--no-compile") +except ValueError: + try: + from Cython.Compiler.Main import compile + source_root = os.path.dirname(__file__) + compiled_modules = ["Cython.Plex.Scanners"] + extensions = [] + for module in compiled_modules: + source_file = os.path.join(source_root, *module.split('.')) + print("Compiling module %s ..." % module) + result = compile(source_file + ".py") + if result.c_file: + extensions.append( + Extension(module, sources = [result.c_file]) + ) + else: + print("Compilation failed") + if extensions: + setup_args['ext_modules'] = extensions + except Exception: + print("ERROR: %s" % sys.exc_info()[1]) + print("Extension module compilation failed, using plain Python implementation") + + setup( name = 'Cython', version = version,