diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2012-10-07 20:57:24 +0200 |
|---|---|---|
| committer | Stefan Behnel <stefan_ml@behnel.de> | 2012-10-07 20:57:24 +0200 |
| commit | 792c629e2d9490db8993b7665114ddca8a1fb8aa (patch) | |
| tree | 28825a6e7ef8fba178517e718e1ce8b8fb59d3d3 /setupinfo.py | |
| parent | 8d9daa7c5ce142a3156c5aa7703d69fd2bb54f70 (diff) | |
| download | python-lxml-792c629e2d9490db8993b7665114ddca8a1fb8aa.tar.gz | |
only use Cython for building when required or explicitly requested
Diffstat (limited to 'setupinfo.py')
| -rw-r--r-- | setupinfo.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/setupinfo.py b/setupinfo.py index cd8a0511..297b80a2 100644 --- a/setupinfo.py +++ b/setupinfo.py @@ -12,7 +12,7 @@ except ImportError: EXT_MODULES = ["lxml.etree", "lxml.objectify"] -PACKAGE_PATH = "src/lxml/" +PACKAGE_PATH = "src%slxml%s" % (os.path.sep, os.path.sep) INCLUDE_PACKAGE_PATH = PACKAGE_PATH + 'includes' if sys.version_info[0] >= 3: @@ -56,26 +56,29 @@ def ext_modules(static_include_dirs, static_library_dirs, libxslt_version=OPTION_LIBXSLT_VERSION, multicore=OPTION_MULTICORE) - if CYTHON_INSTALLED: + if OPTION_WITHOUT_OBJECTIFY: + modules = [ entry for entry in EXT_MODULES + if 'objectify' not in entry ] + else: + modules = EXT_MODULES + + c_files_exist = [ os.path.exists('%s%s.c' % (PACKAGE_PATH, module)) for module in modules ] + + if CYTHON_INSTALLED and (OPTION_WITH_CYTHON or False in c_files_exist): source_extension = ".pyx" print("Building with Cython %s." % Cython.Compiler.Version.version) - # generate module cleanup code from Cython.Compiler import Options Options.generate_cleanup_code = 3 + elif False in c_files_exist: + for exists, module in zip(c_files_exist, modules): + if not exists: + raise RuntimeError( + "ERROR: Trying to build without Cython, but pre-generated " + "'%s%s.c' is not available." % (PACKAGE_PATH, module)) else: source_extension = ".c" - if not os.path.exists(PACKAGE_PATH + 'lxml.etree.c'): - print ("WARNING: Trying to build without Cython, but pre-generated " - "'%slxml.etree.c' does not seem to be available." % PACKAGE_PATH) - else: - print ("Building without Cython.") - - if OPTION_WITHOUT_OBJECTIFY: - modules = [ entry for entry in EXT_MODULES - if 'objectify' not in entry ] - else: - modules = EXT_MODULES + print("Building without Cython.") lib_versions = get_library_versions() if lib_versions[0]: @@ -347,6 +350,7 @@ OPTION_WITHOUT_OBJECTIFY = has_option('without-objectify') OPTION_WITHOUT_ASSERT = has_option('without-assert') OPTION_WITHOUT_THREADING = has_option('without-threading') OPTION_WITHOUT_CYTHON = has_option('without-cython') +OPTION_WITH_CYTHON = has_option('with-cython') OPTION_WITH_CYTHON_GDB = has_option('cython-gdb') OPTION_WITH_REFNANNY = has_option('with-refnanny') if OPTION_WITHOUT_CYTHON: |
