diff --git a/pygit2/ffi.py b/pygit2/ffi.py index 10762b6..0f225c8 100644 --- a/pygit2/ffi.py +++ b/pygit2/ffi.py @@ -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 ", 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 ", libraries=["git2"], include_dirs=include_dirs, library_dirs=library_dirs) diff --git a/setup.py b/setup.py index 914cbed..27733f4 100644 --- a/setup.py +++ b/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)