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:
@@ -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)
|
||||
|
6
setup.py
6
setup.py
@@ -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)
|
||||
|
Reference in New Issue
Block a user