Importing python-pygit2 correctly on RHEL7.2 (For use in SaltStack gitfs)

269 views Asked by At

I'm trying to setup gitfs for SaltStack, using the pygit2 method. I've installed pygit2 and libgit2 on my machine:

[root@r9tvap1109 site-packages]# yum list installed | grep git2
libgit2.x86_64                        0.21.5-1.el7               @epel
python-pygit2.x86_64                  0.21.4-2.el7               @epel

I've also installed the python-devel package. This is all for Python 2.7.

Whenever I try to import the pygit2 package to test if it was installed correctly I get a bunch of cffi warnings and errors. That ends with this stack trace:

    pygit2/__pycache__/pygit2_cffi_c721781dxbf062fb5.c:6893:21: error: (near initialization for ‘nums[19]’)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pygit2/__init__.py", line 35, in <module>
    from .blame import Blame, BlameHunk
  File "pygit2/blame.py", line 32, in <module>
    from .errors import check_error
  File "pygit2/errors.py", line 29, in <module>
    from .ffi import ffi, C
  File "pygit2/ffi.py", line 35, in <module>
    ffi, C = get_ffi()
  File "pygit2/_utils.py", line 101, in get_ffi
    include_dirs=[libgit2_include], library_dirs=[libgit2_lib])
  File "cffi/api.py", line 450, in verify
    lib = self.verifier.load_library()
  File "cffi/verifier.py", line 113, in load_library
    self._compile_module()
  File "cffi/verifier.py", line 210, in _compile_module
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "cffi/ffiplatform.py", line 29, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose)
  File "cffi/ffiplatform.py", line 62, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: CompileError: command 'gcc' failed with exit status 1

Here is a list of things I've tried:

  • uninstalling/reinstalling (using yum)
  • Installing libgit2 via binaries, then trying to install pygit2 using pip (also fails due to GCC compiler error).
  • Verified that I have a GCC compiler installed
  • Tried moving cffi file found in /usr/lib64/python2.7/site-packages to [..]pygit2/pycache/
  • Done some searching on other questions - I found this link See comment by JDavid about half way down about 2 solutions

Any help is appreciated

1

There are 1 answers

0
Phillip Pinto On

I figured out the problem - I had a newer version of python-cffi than the package would support. I downgraded from 1.6.0-5 to 0.8.6-2