在RHEL7.2上正确导入python-pygit2(用于SaltStack gitfs)

时间:2016-12-13 16:21:54

标签: python python-2.7 salt-stack pygit2 gitfs

我正在尝试使用pygit2方法为SaltStack设置gitfs。我在我的机器上安装了pygit2和libgit2:

[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

我还安装了python-devel包。这完全适用于Python 2.7。

每当我尝试导入pygit2包以测试它是否正确安装时,我会收到一堆cffi警告和错误。以堆栈跟踪结束:

    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

以下列出了我尝试过的事情:

  • 卸载/重新安装(使用yum)
  • 通过二进制文件安装libgit2,然后尝试使用pip安装pygit2(由于GCC编译器错误也失败)。
  • 已确认我已安装GCC编译器
  • 尝试将/usr/lib64/python2.7/site-packages中的 cffi 文件移至[..] pygit2 / pycache /
  • 在其他问题上进行了一些搜索 - 我找到了这个链接See comment by JDavid about half way down about 2 solutions

感谢任何帮助

1 个答案:

答案 0 :(得分:0)

我想出了问题 - 我有一个比包支持的更新版本的python-cffi。我从1.6.0-5降级到0.8.6-2