##// END OF EJS Templates
packaging: add Bullseye, remove Jessie...
packaging: add Bullseye, remove Jessie Jessie is oldoldstable now, and Bullseye is going to be the next stable (now testing). We're continuing to support the current oldstable, stable and testing releases. Differential Revision: https://phab.mercurial-scm.org/D6762

File last commit:

r42237:675775c3 default
r43077:0a50a423 stable
Show More
setup_zstd.py
190 lines | 5.6 KiB | text/x-python | PythonLexer
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 # Copyright (c) 2016-present, Gregory Szorc
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 import distutils.ccompiler
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 import os
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 from distutils.extension import Extension
zstd_sources = ['zstd/%s' % p for p in (
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 'common/debug.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'common/entropy_common.c',
'common/error_private.c',
'common/fse_decompress.c',
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 'common/pool.c',
'common/threading.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'common/xxhash.c',
'common/zstd_common.c',
'compress/fse_compress.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 'compress/hist.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'compress/huf_compress.c',
'compress/zstd_compress.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 'compress/zstd_double_fast.c',
'compress/zstd_fast.c',
'compress/zstd_lazy.c',
'compress/zstd_ldm.c',
'compress/zstd_opt.c',
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 'compress/zstdmt_compress.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'decompress/huf_decompress.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.11...
r42237 'decompress/zstd_ddict.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'decompress/zstd_decompress.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.11...
r42237 'decompress/zstd_decompress_block.c',
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 'dictBuilder/cover.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'dictBuilder/divsufsort.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 'dictBuilder/fastcover.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'dictBuilder/zdict.c',
)]
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 zstd_sources_legacy = ['zstd/%s' % p for p in (
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 'deprecated/zbuff_common.c',
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 'deprecated/zbuff_compress.c',
'deprecated/zbuff_decompress.c',
'legacy/zstd_v01.c',
'legacy/zstd_v02.c',
'legacy/zstd_v03.c',
'legacy/zstd_v04.c',
'legacy/zstd_v05.c',
'legacy/zstd_v06.c',
'legacy/zstd_v07.c'
)]
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
zstd_includes = [
'zstd',
'zstd/common',
'zstd/compress',
'zstd/decompress',
'zstd/dictBuilder',
]
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 zstd_includes_legacy = [
'zstd/deprecated',
'zstd/legacy',
]
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 ext_includes = [
'c-ext',
'zstd/common',
]
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ext_sources = [
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 'zstd/common/pool.c',
'zstd/common/threading.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'zstd.c',
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 'c-ext/bufferutil.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'c-ext/compressiondict.c',
'c-ext/compressobj.c',
'c-ext/compressor.c',
'c-ext/compressoriterator.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 'c-ext/compressionchunker.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'c-ext/compressionparams.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 'c-ext/compressionreader.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'c-ext/compressionwriter.c',
'c-ext/constants.c',
'c-ext/decompressobj.c',
'c-ext/decompressor.c',
'c-ext/decompressoriterator.c',
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 'c-ext/decompressionreader.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 'c-ext/decompressionwriter.c',
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 'c-ext/frameparams.c',
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ]
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 zstd_depends = [
'c-ext/python-zstandard.h',
]
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 def get_c_extension(support_legacy=False, system_zstd=False, name='zstd',
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 warnings_as_errors=False, root=None):
"""Obtain a distutils.extension.Extension for the C extension.
``support_legacy`` controls whether to compile in legacy zstd format support.
``system_zstd`` controls whether to compile against the system zstd library.
For this to work, the system zstd library and headers must match what
python-zstandard is coded against exactly.
``name`` is the module name of the C extension to produce.
``warnings_as_errors`` controls whether compiler warnings are turned into
compiler errors.
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 ``root`` defines a root path that source should be computed as relative
to. This should be the directory with the main ``setup.py`` that is
being invoked. If not defined, paths will be relative to this file.
"""
actual_root = os.path.abspath(os.path.dirname(__file__))
root = root or actual_root
sources = set([os.path.join(actual_root, p) for p in ext_sources])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if not system_zstd:
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 sources.update([os.path.join(actual_root, p) for p in zstd_sources])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if support_legacy:
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 sources.update([os.path.join(actual_root, p)
for p in zstd_sources_legacy])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 sources = list(sources)
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 include_dirs = set([os.path.join(actual_root, d) for d in ext_includes])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if not system_zstd:
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 include_dirs.update([os.path.join(actual_root, d)
for d in zstd_includes])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if support_legacy:
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 include_dirs.update([os.path.join(actual_root, d)
for d in zstd_includes_legacy])
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 include_dirs = list(include_dirs)
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 depends = [os.path.join(actual_root, p) for p in zstd_depends]
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 compiler = distutils.ccompiler.new_compiler()
# Needed for MSVC.
if hasattr(compiler, 'initialize'):
compiler.initialize()
if compiler.compiler_type == 'unix':
compiler_type = 'unix'
elif compiler.compiler_type == 'msvc':
compiler_type = 'msvc'
Gregory Szorc
zstandard: pull in bug fixes from upstream 0.9.1 release (issue5884)...
r38244 elif compiler.compiler_type == 'mingw32':
compiler_type = 'mingw32'
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 else:
raise Exception('unhandled compiler type: %s' %
compiler.compiler_type)
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 extra_args = ['-DZSTD_MULTITHREAD']
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if not system_zstd:
extra_args.append('-DZSTDLIB_VISIBILITY=')
extra_args.append('-DZDICTLIB_VISIBILITY=')
extra_args.append('-DZSTDERRORLIB_VISIBILITY=')
if compiler_type == 'unix':
extra_args.append('-fvisibility=hidden')
if not system_zstd and support_legacy:
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 extra_args.append('-DZSTD_LEGACY_SUPPORT=1')
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 if warnings_as_errors:
Gregory Szorc
zstandard: pull in bug fixes from upstream 0.9.1 release (issue5884)...
r38244 if compiler_type in ('unix', 'mingw32'):
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 extra_args.append('-Werror')
elif compiler_type == 'msvc':
extra_args.append('/WX')
else:
assert False
libraries = ['zstd'] if system_zstd else []
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 # Python 3.7 doesn't like absolute paths. So normalize to relative.
sources = [os.path.relpath(p, root) for p in sources]
include_dirs = [os.path.relpath(p, root) for p in include_dirs]
depends = [os.path.relpath(p, root) for p in depends]
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 # TODO compile with optimizations.
return Extension(name, sources,
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 include_dirs=include_dirs,
depends=depends,
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 extra_compile_args=extra_args,
libraries=libraries)