diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-24 00:08:01 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-03-24 00:08:01 (GMT) |
commit | 440ca772f33b7c2eae1beb2e26a643d3054066f9 (patch) | |
tree | 36a32eb2c87e44aef782ae545d675172cf4db025 /setup.py | |
parent | dd10284516383276d50ae9b52bec4ab6562f888e (diff) | |
download | cpython-440ca772f33b7c2eae1beb2e26a643d3054066f9.zip cpython-440ca772f33b7c2eae1beb2e26a643d3054066f9.tar.gz cpython-440ca772f33b7c2eae1beb2e26a643d3054066f9.tar.bz2 |
Have the binascii module use zlib's optimized crc32() function when available
to reduce our code size (1k data table and tiny bit of code). It falls back
to its own without zlib.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -486,9 +486,6 @@ class PyBuildExt(build_ext): # select(2); not on ancient System V exts.append( Extension('select', ['selectmodule.c']) ) - # Helper module for various ascii-encoders - exts.append( Extension('binascii', ['binascii.c']) ) - # Fred Drake's interface to the Python parser exts.append( Extension('parser', ['parsermodule.c']) ) @@ -1069,6 +1066,7 @@ class PyBuildExt(build_ext): # You can upgrade zlib to version 1.1.4 yourself by going to # http://www.gzip.org/zlib/ zlib_inc = find_file('zlib.h', [], inc_dirs) + have_zlib = False if zlib_inc is not None: zlib_h = zlib_inc[0] + '/zlib.h' version = '"0.0.0"' @@ -1090,6 +1088,7 @@ class PyBuildExt(build_ext): exts.append( Extension('zlib', ['zlibmodule.c'], libraries = ['z'], extra_link_args = zlib_extra_link_args)) + have_zlib = True else: missing.append('zlib') else: @@ -1097,6 +1096,21 @@ class PyBuildExt(build_ext): else: missing.append('zlib') + # Helper module for various ascii-encoders. Uses zlib for an optimized + # crc32 if we have it. Otherwise binascii uses its own. + if have_zlib: + extra_compile_args = ['-DUSE_ZLIB_CRC32'] + libraries = ['z'] + extra_link_args = zlib_extra_link_args + else: + extra_compile_args = [] + libraries = [] + extra_link_args = [] + exts.append( Extension('binascii', ['binascii.c'], + extra_compile_args = extra_compile_args, + libraries = libraries, + extra_link_args = extra_link_args) ) + # Gustavo Niemeyer's bz2 module. if (self.compiler.find_library_file(lib_dirs, 'bz2')): if sys.platform == "darwin": |