libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.59k stars 383 forks source link

build: requires libgit2 1.2.x #1089

Closed chenrui333 closed 2 years ago

chenrui333 commented 2 years ago

relates to https://github.com/Homebrew/homebrew-core/pull/84518

  src/types.h:36:2: error: You need a compatible libgit2 version (1.1.x)
  #error You need a compatible libgit2 version (1.1.x)
   ^
chenrui333 commented 2 years ago

@adamgolebiowski any chance of merging this?

jdavid commented 2 years ago

For this to be merged CI must be updated to use 1.2 instead of 1.1

Mindavi commented 2 years ago

These lines at least:

https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/.travis.yml#L32

https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/Makefile#L4

https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/appveyor.yml#L38

https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/.github/workflows/wheels.yml#L9

https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/.github/workflows/tests.yml#L33

alerque commented 2 years ago

Having tried to apply this PR as a patch, it looks like it builds but a large portion of the test suite starts failing with errors like this:

ffi.error: struct git_remote_callbacks: wrong offset for field 'payload' (cdef says 96, but C compiler says 104). fix it or use "...;" as the last field in the cdef for struct git_remote_callbacks to make it flexible

carlocab commented 2 years ago

Yea, libgit2 added a new field to the git_remote_callbacks struct in https://github.com/libgit2/libgit2/commit/72df17c659619707e4e5f27b2a51db60848a1d04#, so the offset for the payload field should indeed be 104.

alerque commented 2 years ago

@carlocab Any chance you can make that adjustment in this PR?

carlocab commented 2 years ago

I'm not familiar enough with the code here to know what the right adjustment is. Do you have a backtrace for the error you saw?

alerque commented 2 years ago

Here is the first of 12 failed / 14 errors I get when applying this PR as a patch to 1.6.1 sources, then building against libgit2-1.2.0, then running python setup.py pytest:

==================================== ERRORS ====================================
__________________ ERROR at setup of test_branches_remote_get __________________

emptyrepo = pygit2.Repository('/tmp/pytest-of-builduser/pytest-0/test_branches_remote_get0/emptyrepo/.git/')

    @pytest.fixture
    def repo(emptyrepo):
        remote = emptyrepo.remotes[0]
>       remote.fetch()

test/test_branch_empty.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pygit2/remote.py:141: in fetch
    with git_fetch_options(callbacks) as payload:
/usr/lib/python3.9/contextlib.py:119: in __enter__
    return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

payload = <pygit2.callbacks.RemoteCallbacks object at 0x7fdcd1673ac0>
opts = None

    @contextmanager
    def git_fetch_options(payload, opts=None):
        if payload is None:
            payload = RemoteCallbacks()

        if opts is None:
>           opts = ffi.new('git_fetch_options *')
E           ffi.error: struct git_remote_callbacks: wrong offset for field 'payload' (cdef says 96, but C compiler says 104). fix it or use "...;" as the last field in the cdef for struct git_remote_callbacks to make it flexible

pygit2/callbacks.py:247: error
____________________ ERROR at setup of test_branches_remote ____________________

emptyrepo = pygit2.Repository('/tmp/pytest-of-builduser/pytest-0/test_branches_remote0/emptyrepo/.git/')

    @pytest.fixture
    def repo(emptyrepo):
        remote = emptyrepo.remotes[0]
>       remote.fetch()
carlocab commented 2 years ago

Thanks for the fix, @jdavid.

Here's https://github.com/libgit2/pygit2/commit/dcde9eff5950492ab0d2565a07fd18d765332a96 amended so that it applies to the PyPI tarball, in case anyone needs it:

https://raw.githubusercontent.com/Homebrew/formula-patches/bf370d7782f7686a4a61d8d7d28068e78e28e48c/pygit2/libgit2-1.2.0.patch