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

Skip to content

Commit e697091

Browse files
committed
Patch by Mark Favas to ensure that the zlib we find is 1.1.3 or
later. This assumes that zlib.h has a line of the form #define ZLIB_VERSION "1.1.3" This solves the problem where a zlib installation is found but it is an older version -- this would break the build, while a better solution is to simply ignore that zlib installation.
1 parent 2b5ff07 commit e697091

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

setup.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,23 @@ def detect_modules(self):
449449
# Andrew Kuchling's zlib module.
450450
# This require zlib 1.1.3 (or later).
451451
# See http://www.cdrom.com/pub/infozip/zlib/
452-
if (self.compiler.find_library_file(lib_dirs, 'z')):
453-
exts.append( Extension('zlib', ['zlibmodule.c'],
454-
libraries = ['z']) )
452+
zlib_inc = find_file('zlib.h', [], inc_dirs)
453+
if zlib_inc is not None:
454+
zlib_h = zlib_inc[0] + '/zlib.h'
455+
version = '"0.0.0"'
456+
version_req = '"1.1.3"'
457+
fp = open(zlib_h)
458+
while 1:
459+
line = fp.readline()
460+
if not line:
461+
break
462+
if line.find('#define ZLIB_VERSION', 0) == 0:
463+
version = line.split()[2]
464+
break
465+
if version >= version_req:
466+
if (self.compiler.find_library_file(lib_dirs, 'z')):
467+
exts.append( Extension('zlib', ['zlibmodule.c'],
468+
libraries = ['z']) )
455469

456470
# Interface to the Expat XML parser
457471
#

0 commit comments

Comments
 (0)