Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a99202a

Browse files
committed
Fix for bug #129173, reported by Skip Montanaro:
Check for the two possible headers for Expat, expat.h and xmlparse.h, and only compile the pyexpat module if one of them is found.
1 parent 33b4d50 commit a99202a

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

setup.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def detect_modules(self):
6868
# a fixed list
6969
lib_dirs = self.compiler.library_dirs[:]
7070
lib_dirs += ['/lib', '/usr/lib', '/usr/local/lib']
71+
inc_dirs = ['/usr/include', '/usr/local/include'] + self.include_dirs
7172
exts = []
7273

7374
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -232,8 +233,7 @@ def detect_modules(self):
232233
# Setup.config before enabling it here.
233234

234235
if (self.compiler.find_library_file(lib_dirs, 'db') and
235-
find_file(['/usr/include', '/usr/local/include'] + self.include_dirs,
236-
'db_185.h') ):
236+
find_file(inc_dirs, 'db_185.h') ):
237237
exts.append( Extension('bsddb', ['bsddbmodule.c'],
238238
libraries = ['db'] ) )
239239

@@ -340,8 +340,15 @@ def detect_modules(self):
340340
# ar cr libexpat.a xmltok/*.o xmlparse/*.o
341341
#
342342
if (self.compiler.find_library_file(lib_dirs, 'expat')):
343-
exts.append( Extension('pyexpat', ['pyexpat.c'],
344-
libraries = ['expat']) )
343+
defs = None
344+
if find_file(inc_dirs, 'expat.h'):
345+
defs = [('HAVE_EXPAT_H', 1)]
346+
elif find_file(inc_dirs, 'xmlparse.h'):
347+
defs = []
348+
if defs is not None:
349+
exts.append( Extension('pyexpat', ['pyexpat.c'],
350+
define_macros = defs,
351+
libraries = ['expat']) )
345352

346353
# Platform-specific libraries
347354
plat = sys.platform

0 commit comments

Comments
 (0)