equal
deleted
inserted
replaced
3 # All rights reserved. |
3 # All rights reserved. |
4 # |
4 # |
5 # This software may be modified and distributed under the terms |
5 # This software may be modified and distributed under the terms |
6 # of the BSD license. See the LICENSE file for details. |
6 # of the BSD license. See the LICENSE file for details. |
7 |
7 |
|
8 from __future__ import print_function |
|
9 |
|
10 from distutils.version import LooseVersion |
8 import os |
11 import os |
9 import sys |
12 import sys |
10 from setuptools import setup |
13 from setuptools import setup |
11 |
14 |
|
15 # Need change in 1.10 for ffi.from_buffer() to handle all buffer types |
|
16 # (like memoryview). |
|
17 # Need feature in 1.11 for ffi.gc() to declare size of objects so we avoid |
|
18 # garbage collection pitfalls. |
|
19 MINIMUM_CFFI_VERSION = '1.11' |
|
20 |
12 try: |
21 try: |
13 import cffi |
22 import cffi |
|
23 |
|
24 # PyPy (and possibly other distros) have CFFI distributed as part of |
|
25 # them. The install_requires for CFFI below won't work. We need to sniff |
|
26 # out the CFFI version here and reject CFFI if it is too old. |
|
27 cffi_version = LooseVersion(cffi.__version__) |
|
28 if cffi_version < LooseVersion(MINIMUM_CFFI_VERSION): |
|
29 print('CFFI 1.11 or newer required (%s found); ' |
|
30 'not building CFFI backend' % cffi_version, |
|
31 file=sys.stderr) |
|
32 cffi = None |
|
33 |
14 except ImportError: |
34 except ImportError: |
15 cffi = None |
35 cffi = None |
16 |
36 |
17 import setup_zstd |
37 import setup_zstd |
18 |
38 |
47 install_requires = [] |
67 install_requires = [] |
48 |
68 |
49 if cffi: |
69 if cffi: |
50 import make_cffi |
70 import make_cffi |
51 extensions.append(make_cffi.ffi.distutils_extension()) |
71 extensions.append(make_cffi.ffi.distutils_extension()) |
52 |
72 install_requires.append('cffi>=%s' % MINIMUM_CFFI_VERSION) |
53 # Need change in 1.10 for ffi.from_buffer() to handle all buffer types |
|
54 # (like memoryview). |
|
55 # Need feature in 1.11 for ffi.gc() to declare size of objects so we avoid |
|
56 # garbage collection pitfalls. |
|
57 install_requires.append('cffi>=1.11') |
|
58 |
73 |
59 version = None |
74 version = None |
60 |
75 |
61 with open('c-ext/python-zstandard.h', 'r') as fh: |
76 with open('c-ext/python-zstandard.h', 'r') as fh: |
62 for line in fh: |
77 for line in fh: |
86 'Programming Language :: C', |
101 'Programming Language :: C', |
87 'Programming Language :: Python :: 2.7', |
102 'Programming Language :: Python :: 2.7', |
88 'Programming Language :: Python :: 3.4', |
103 'Programming Language :: Python :: 3.4', |
89 'Programming Language :: Python :: 3.5', |
104 'Programming Language :: Python :: 3.5', |
90 'Programming Language :: Python :: 3.6', |
105 'Programming Language :: Python :: 3.6', |
|
106 'Programming Language :: Python :: 3.7', |
91 ], |
107 ], |
92 keywords='zstandard zstd compression', |
108 keywords='zstandard zstd compression', |
93 packages=['zstandard'], |
109 packages=['zstandard'], |
94 ext_modules=extensions, |
110 ext_modules=extensions, |
95 test_suite='tests', |
111 test_suite='tests', |