diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2015-03-19 20:29:01 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2015-03-19 20:29:01 +0100 |
commit | 1524c93dbe5d70262140ddd38ec49ee9d190abb9 (patch) | |
tree | 784ade3a13a59badd77e2e7dc207811cdddd1958 /setupinfo.py | |
parent | 4c70718a0dbb89b5fb87aad91bb57ab40e869b8f (diff) | |
download | python-lxml-1524c93dbe5d70262140ddd38ec49ee9d190abb9.tar.gz |
clean up libxml2 check on build failures
Diffstat (limited to 'setupinfo.py')
-rw-r--r-- | setupinfo.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/setupinfo.py b/setupinfo.py index e2c2dc95..93f0b00d 100644 --- a/setupinfo.py +++ b/setupinfo.py @@ -1,10 +1,10 @@ import sys, os, os.path from distutils.core import Extension from distutils.errors import CompileError, DistutilsOptionError +from distutils.command import build_ext as _build_ext from versioninfo import get_base_dir try: - from Cython.Distutils import build_ext as build_pyx import Cython.Compiler.Version CYTHON_INSTALLED = True except ImportError: @@ -195,28 +195,26 @@ def find_dependencies(module): return pxd_files + pxi_files + def extra_setup_args(): result = {} if CYTHON_INSTALLED: - class CheckLibxml2BuildExt(build_pyx): - """Subclass to check whether libxml2 is available""" + class CheckLibxml2BuildExt(_build_ext): + """Subclass to check whether libxml2 is really available if the build fails""" def run(self): try: - build_pyx.run(self) + super(CheckLibxml2BuildExt, self).run(self) except CompileError as e: print('Compile failed: %s' % e) if not has_libxml2(): - sys.stderr.write('*********************************************************************************\n') - sys.stderr.write('Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?\n') - if sys.platform in ('darwin',): - sys.stderr.write('Perhaps try: xcode-select --install\n') - sys.stderr.write('*********************************************************************************\n') + print_libxml_error() raise result['cmdclass'] = {'build_ext': CheckLibxml2BuildExt} return result + def has_libxml2(): from distutils import ccompiler compiler = ccompiler.new_compiler() @@ -225,6 +223,15 @@ def has_libxml2(): include_dirs=['/usr/include/libxml2'], includes=['libxml/xpath.h'], libraries=['xml2']) + +def print_libxml_error(): + print('*********************************************************************************') + print('Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?') + if sys.platform in ('darwin',): + print('Perhaps try: xcode-select --install') + print('*********************************************************************************') + + def libraries(): if sys.platform in ('win32',): libs = ['libxslt', 'libexslt', 'libxml2', 'iconv'] |