From ec23762c09ce23a58f81cac98e65e55be42dc3f5 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Wed, 9 Sep 2015 22:25:20 +0200 Subject: [PATCH] Add support for cffi-pre-1.0 --- pygit2/ffi.py | 4 ++-- setup.py | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/pygit2/ffi.py b/pygit2/ffi.py index 47542a1..95c8e4e 100644 --- a/pygit2/ffi.py +++ b/pygit2/ffi.py @@ -32,5 +32,5 @@ from __future__ import absolute_import try: from ._libgit2 import ffi, lib as C except ImportError: - from .libgit2_build import ffi, C_HEADER_SRC, C_KEYWORDS - C = ffi.verify(C_HEADER_SRC, **C_KEYWORDS) + from .libgit2_build import ffi, preamble, C_KEYWORDS + C = ffi.verify(preamble, **C_KEYWORDS) diff --git a/setup.py b/setup.py index dd61796..8b37b0f 100644 --- a/setup.py +++ b/setup.py @@ -45,9 +45,16 @@ from subprocess import Popen, PIPE import sys import unittest +# Get cffi major version +import cffi +cffi_major_version = cffi.__version_info__[0] + # Import stuff from pygit2/_utils.py without loading the whole pygit2 package sys.path.insert(0, 'pygit2') from libgit2_build import __version__, get_libgit2_paths +if cffi_major_version == 0: + from libgit2_build import ffi, preamble, C_KEYWORDS + ffi.verify(preamble, **C_KEYWORDS) del sys.path[0] # Python 2 support @@ -163,6 +170,21 @@ class BuildWithDLLs(build): if os.name == 'nt': cmdclass['build'] = BuildWithDLLs +extra_args = { + 'ext_modules': [ + Extension('_pygit2', pygit2_exts, libraries=['git2'], + include_dirs=[libgit2_include], + library_dirs=[libgit2_lib]), + # FFI is added in the build step + ], +} + +if cffi_major_version == 0: + extra_args['ext_modules'].append(ffi.verifier.get_extension()) +else: + extra_args['cffi_modules']=['pygit2/libgit2_build.py:ffi'] + + setup(name='pygit2', description='Python bindings for libgit2.', keywords='git', @@ -175,14 +197,8 @@ setup(name='pygit2', long_description=long_description, packages=['pygit2'], package_data={'pygit2': ['decl.h']}, - cffi_modules=['pygit2/libgit2_build.py:ffi'], setup_requires=['cffi'], install_requires=['cffi'], zip_safe=False, - ext_modules=[ - Extension('_pygit2', pygit2_exts, libraries=['git2'], - include_dirs=[libgit2_include], - library_dirs=[libgit2_lib]), - # FFI is added in the build step - ], - cmdclass=cmdclass) + cmdclass=cmdclass, + **extra_args)