-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
executable file
·96 lines (87 loc) · 2.96 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python
"""
pyzopfli
======
Python bindings to zopfli
"""
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from io import open
import os
class custom_build_ext(build_ext):
"""Pass platform-specific compiler/linker flags"""
def build_extensions(self):
compiler_type = self.compiler.compiler_type
if compiler_type in "unix":
for ext in self.extensions:
# on some Unix-like systems, such as Linux, the libc math
# library is not linked by default:
# https://github.com/cython/cython/issues/1585
ext.extra_link_args.append("-lm")
build_ext.build_extensions(self)
with open("README.rst", "r", encoding="utf-8") as readme:
long_description = readme.read()
prefer_system_zopfli = bool(os.environ.get('USE_SYSTEM_ZOPFLI'))
if prefer_system_zopfli:
zopfli_ext_kwargs = {
'sources': [
'src/zopflimodule.c',
],
'libraries': ['zopfli', 'zopflipng'],
'define_macros': [('SYSTEM_ZOPFLI', '1')],
}
else:
zopfli_ext_kwargs = {
'sources': [
'zopfli/src/zopfli/blocksplitter.c',
'zopfli/src/zopfli/cache.c',
'zopfli/src/zopfli/deflate.c',
'zopfli/src/zopfli/gzip_container.c',
'zopfli/src/zopfli/squeeze.c',
'zopfli/src/zopfli/hash.c',
'zopfli/src/zopfli/katajainen.c',
'zopfli/src/zopfli/lz77.c',
'zopfli/src/zopfli/tree.c',
'zopfli/src/zopfli/util.c',
'zopfli/src/zopfli/zlib_container.c',
'zopfli/src/zopfli/zopfli_lib.c',
'zopfli/src/zopflipng/lodepng/lodepng.cpp',
'zopfli/src/zopflipng/lodepng/lodepng_util.cpp',
'zopfli/src/zopflipng/zopflipng_lib.cc',
'src/zopflimodule.c',
],
}
setup(
name='zopfli',
use_scm_version={"write_to": "src/zopfli/_version.py"},
author='Adam DePrince',
author_email='[email protected]',
maintainer='Cosimo Lupo',
maintainer_email='[email protected]',
description='Zopfli module for python',
long_description=long_description,
ext_modules=[
Extension('zopfli.zopfli', **zopfli_ext_kwargs)
],
package_dir={"": "src"},
packages=["zopfli"],
zip_safe=True,
license='ASL',
include_package_data=True,
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: System :: Archiving :: Compression',
],
url="https://github.com/fonttools/py-zopfli",
test_suite="tests",
cmdclass={
"build_ext": custom_build_ext,
},
setup_requires=["setuptools_scm"],
extras_require={"test": ["pytest"]},
python_requires=">=3.8",
)