45
45
import sys
46
46
import unittest
47
47
48
+ # Get cffi major version
49
+ import cffi
50
+ cffi_major_version = cffi .__version_info__ [0 ]
51
+
48
52
# Import stuff from pygit2/_utils.py without loading the whole pygit2 package
49
53
sys .path .insert (0 , 'pygit2' )
50
54
from libgit2_build import __version__ , get_libgit2_paths
55
+ if cffi_major_version == 0 :
56
+ from libgit2_build import ffi , preamble , C_KEYWORDS
57
+ ffi .verify (preamble , ** C_KEYWORDS )
51
58
del sys .path [0 ]
52
59
53
60
# Python 2 support
@@ -163,6 +170,21 @@ def run(self):
163
170
if os .name == 'nt' :
164
171
cmdclass ['build' ] = BuildWithDLLs
165
172
173
+ extra_args = {
174
+ 'ext_modules' : [
175
+ Extension ('_pygit2' , pygit2_exts , libraries = ['git2' ],
176
+ include_dirs = [libgit2_include ],
177
+ library_dirs = [libgit2_lib ]),
178
+ # FFI is added in the build step
179
+ ],
180
+ }
181
+
182
+ if cffi_major_version == 0 :
183
+ extra_args ['ext_modules' ].append (ffi .verifier .get_extension ())
184
+ else :
185
+ extra_args ['cffi_modules' ]= ['pygit2/libgit2_build.py:ffi' ]
186
+
187
+
166
188
setup (name = 'pygit2' ,
167
189
description = 'Python bindings for libgit2.' ,
168
190
keywords = 'git' ,
@@ -175,14 +197,8 @@ def run(self):
175
197
long_description = long_description ,
176
198
packages = ['pygit2' ],
177
199
package_data = {'pygit2' : ['decl.h' ]},
178
- cffi_modules = ['pygit2/libgit2_build.py:ffi' ],
179
200
setup_requires = ['cffi' ],
180
201
install_requires = ['cffi' ],
181
202
zip_safe = False ,
182
- ext_modules = [
183
- Extension ('_pygit2' , pygit2_exts , libraries = ['git2' ],
184
- include_dirs = [libgit2_include ],
185
- library_dirs = [libgit2_lib ]),
186
- # FFI is added in the build step
187
- ],
188
- cmdclass = cmdclass )
203
+ cmdclass = cmdclass ,
204
+ ** extra_args )
0 commit comments