Index: setup.py =================================================================== --- setup.py (revision 72608) +++ setup.py (working copy) @@ -1148,30 +1148,39 @@ # http://www.gzip.org/zlib/ zlib_inc = find_file('zlib.h', [], inc_dirs) have_zlib = False - if zlib_inc is not None: + zlibdir = None + shipped_zlibdir = os.path.join(os.path.abspath('.'), 'Modules/zlib') + shipped_zlib_inc = find_file('zlib.h', [], [shipped_zlibdir]) + # We ship zlib, so use it if system version is bad + if zlib_inc is None: + zlibdir, zlib_inc = shipped_zlibdir, shipped_zlib_inc + zlib_h = zlib_inc[0] + '/zlib.h' + version = '"0.0.0"' + version_req = '"1.1.3"' + fp = open(zlib_h) + while 1: + line = fp.readline() + if not line: + break + if line.startswith('#define ZLIB_VERSION'): + version = line.split()[2] + break + # We ship zlib, so use it if system version is bad + if version < version_req and zlibdir is None: + zlibdir, zlib_inc = shipped_zlibdir, shipped_zlib_inc zlib_h = zlib_inc[0] + '/zlib.h' - version = '"0.0.0"' - version_req = '"1.1.3"' - fp = open(zlib_h) - while 1: - line = fp.readline() - if not line: - break - if line.startswith('#define ZLIB_VERSION'): - version = line.split()[2] - break - if version >= version_req: - if (self.compiler.find_library_file(lib_dirs, 'z')): - if sys.platform == "darwin": - zlib_extra_link_args = ('-Wl,-search_paths_first',) - else: - zlib_extra_link_args = () - exts.append( Extension('zlib', ['zlibmodule.c'], - libraries = ['z'], - extra_link_args = zlib_extra_link_args)) - have_zlib = True + version = '"1.1.3"' + if version >= version_req: + if (self.compiler.find_library_file(lib_dirs, 'z')) or zlibdir: + if sys.platform == "darwin": + zlib_extra_link_args = ('-Wl,-search_paths_first',) else: - missing.append('zlib') + zlib_extra_link_args = () + exts.append( Extension('zlib', ['zlibmodule.c'], + libraries = ['z'], + include_dirs = zlib_inc, + extra_link_args = zlib_extra_link_args)) + have_zlib = True else: missing.append('zlib') else: @@ -1190,6 +1199,7 @@ exts.append( Extension('binascii', ['binascii.c'], extra_compile_args = extra_compile_args, libraries = libraries, + include_dirs = zlib_inc, extra_link_args = extra_link_args) ) # Gustavo Niemeyer's bz2 module.