Skip to content

Runtime failures delivered by multiple package managers #558

Closed

Description

@ajnelson-nist

Hello,

I was using Pygit2 as packaged by MacPorts successfully a week or three ago. I've been keeping my MacPorts tree up to date regularly. Today, I tried using Pygit2 again (port py34-pygit2), and I received an asynchronous error. The traceback started after I receive the prompt for the next command.

$ python3.4
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/__init__.py", line 35, in <module>
    from .blame import Blame, BlameHunk
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/blame.py", line 32, in <module>
    from .errors import check_error
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/errors.py", line 29, in <module>
    from .ffi import ffi, C
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/ffi.py", line 35, in <module>
    ffi, C = get_ffi()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/_utils.py", line 107, in get_ffi
    include_dirs=[libgit2_include], library_dirs=[libgit2_lib])
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/cffi/api.py", line 405, in verify
    lib = self.verifier.load_library()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/cffi/verifier.py", line 99, in load_library
    self._write_source()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/cffi/verifier.py", line 187, in _write_source
    with open(self.sourcefilename, "w") as fp:
PermissionError: [Errno 13] Permission denied: '/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygit2/__pycache__/pygit2_cffi_a295dec8x2a59b7ee.c'

This issue looks similar to the build failure currently being experienced in the next Ubuntu's nightly builds. According to the Launchpad issue tracker, the upstream Debian issue has not been resolved yet.

It looks like this is related to a cffi update, according to Issue 534.

So it's clear: Pygit2 currently fails as packaged by three operating systems using two package management systems. It looks like at least one additional file needs to be built during the build scripts, but I'm not sure if that's the correct solution or a hack.

Activity

  1. galactics commented on Aug 30, 2015

    @galactics

    I have the same problem with ArchLinux,

    $ python
    Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
    [GCC 4.9.2 20150304 (prerelease)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pygit2
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.4/site-packages/pygit2/__init__.py", line 35, in <module>
        from .blame import Blame, BlameHunk
      File "/usr/lib/python3.4/site-packages/pygit2/blame.py", line 32, in <module>
        from .errors import check_error
      File "/usr/lib/python3.4/site-packages/pygit2/errors.py", line 29, in <module>
        from .ffi import ffi, C
      File "/usr/lib/python3.4/site-packages/pygit2/ffi.py", line 35, in <module>
        ffi, C = get_ffi()
      File "/usr/lib/python3.4/site-packages/pygit2/_utils.py", line 107, in get_ffi
        include_dirs=[libgit2_include], library_dirs=[libgit2_lib])
      File "/usr/lib/python3.4/site-packages/cffi/api.py", line 405, in verify
        lib = self.verifier.load_library()
      File "/usr/lib/python3.4/site-packages/cffi/verifier.py", line 99, in load_library
        self._write_source()
      File "/usr/lib/python3.4/site-packages/cffi/verifier.py", line 187, in _write_source
        with open(self.sourcefilename, "w") as fp:
    PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.4/site-packages/pygit2/__pycache__/pygit2_cffi_a295dec8x2a59b7ee.c'
    >>> 
    

    I found a way to get around the problem, by installing everything in the user .local folder.

    $ pip install --user pygit2
    

    But it's not a good long term solution

  2. jdavid commented on Sep 2, 2015

    @jdavid
    Member

    My hypothesis...

    So pygit2 is installed system wide, the cffi extension should be built and installed, and probably it is. But when importing it is not found, so it tries to generate it at runtime. Since all this happens as a regular user, without write access, you get an error.

    The name of the cffi extension is defined by https://github.com/libgit2/pygit2/blob/master/pygit2/_utils.py#L75 and depends on a number of variables, like the version of cffi. This means for instance that the binary package in your distribution needs to be updated every time there is a new version of cffi.

    For context you may check issue #441

    One possible solution would be to reduce the number of variables the name of the cffi extension depends
    on.

    But then there is #529 ... I have to check how the new method works.

  3. jdavid commented on Sep 2, 2015

    @jdavid
    Member

    Interesting, it looks like the name is constant with the new method.

    Before:

    $ find build -name "*.so"
    build/lib.linux-x86_64-2.7/_pygit2.so
    build/lib.linux-x86_64-2.7/pygit2_cffi_51591433xe8494016.so
    

    After:

    $ find build -name "*.so"
    build/lib.linux-x86_64-2.7/_pygit2.so
    build/lib.linux-x86_64-2.7/pygit2/_libgit2.so
    

    Looks like a good reason to merge #529 and drop support for older versions of cffi.

  4. ajnelson-nist commented on Sep 14, 2015

    @ajnelson-nist
    Author

    I updated MacPorts today and saw pygit2 and some dependencies were changed. Pygit2 now functions as expected on OS X.

    I also tested the Ubuntu nightly build, and found it was fixed. Debian reports a fix as well. It looks like this issue is resolved. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions