Fix installation-time cffi compilation

The documentation recommends adding the ffi code as an extension so it
gets built at the right time.

Make use of the LIBGIT2 environment variable to build and link the ffi
module the same way the C extension does so the user doesn't have to
export CFLAGS.
This commit is contained in:
Carlos Martín Nieto
2014-04-13 20:37:58 +02:00
parent b4bc2b6295
commit f3bb8a4556
2 changed files with 15 additions and 1 deletions

View File

@@ -104,4 +104,12 @@ decl_path = path.join(dir_path, 'decl.h')
with codecs.open(decl_path, 'r', 'utf-8') as header:
ffi.cdef(header.read())
C = ffi.verify("#include <git2.h>", libraries=["git2"])
# if LIBGIT2 exists, set build and link against that version
libgit2_path = getenv('LIBGIT2')
include_dirs = []
library_dirs = []
if libgit2_path:
include_dirs = [path.join(libgit2_path, 'include')]
library_dirs = [path.join(libgit2_path, 'lib')]
C = ffi.verify("#include <git2.h>", libraries=["git2"], include_dirs=include_dirs, library_dirs=library_dirs)

View File

@@ -173,6 +173,11 @@ classifiers = [
with codecs.open('README.rst', 'r', 'utf-8') as readme:
long_description = readme.read()
# This ffi is pygit2.ffi due to the path trick used in the beginning
# of the file
from ffi import ffi
ffi_ext = ffi.verifier.get_extension()
setup(name='pygit2',
description='Python bindings for libgit2.',
keywords='git',
@@ -191,5 +196,6 @@ setup(name='pygit2',
include_dirs=[libgit2_include, 'include'],
library_dirs=[libgit2_lib],
libraries=['git2']),
ffi_ext,
],
cmdclass=cmdclass)