libgit2 / pygit2

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

_libgit2.abi3.so not created in a flatpak build for flathub #1218

Closed philippun1 closed 9 months ago

philippun1 commented 1 year ago

Hello,

I'm currently trying to build pygit2 as a dependency for a flatpak on flathub: https://github.com/flathub/flathub/pull/4082

Everything seems to work fine, but the _libgit2.abi3.so seems not to be created. The full command for the actual pygit2 install would be pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "pygit2" --no-build-isolation. libgit2 and the other dependencies are build from source, because it is not allowed to download them during build on flathub.

Here is the full build log of the flatpak: flatpak-build-with-pygit2.log

Since the build succeeds I assume the libgit2 dependency gets detected properly, the libgit2.so* files are also created into the output directory under .../lib.

In the log you can see building 'pygit2._pygit2' extension is being built, but the building 'pygit2._libgit2' extension is missing. I built libgit2 and pygit2 locally as described here to compare and the pygit2._libgit2 extension gets built.

Is there something I am missing? Maybe a parameter for the pip3 build?

philippun1 commented 1 year ago

If I try to start the flatpak with `` this error is shown:

Traceback (most recent call last):
  File "/app/bin/turtle_cli", line 20, in <module>
    import turtlevcs
  File "/app/lib/python3.10/site-packages/turtlevcs/__init__.py", line 21, in <module>
    import pygit2
  File "/app/lib/python3.10/site-packages/pygit2/__init__.py", line 33, in <module>
    from .blame import Blame, BlameHunk
  File "/app/lib/python3.10/site-packages/pygit2/blame.py", line 27, in <module>
    from .ffi import ffi, C
  File "/app/lib/python3.10/site-packages/pygit2/ffi.py", line 27, in <module>
    from ._libgit2 import ffi, lib as C
ModuleNotFoundError: No module named 'pygit2._libgit2'

If I copy the _libgit2.abi3.so into the flatpak runtime folder it will run properly. So the file is the only missing part.

Currently I'm trying to find the difference between the created files from the regular build and the flatpak build. The Extension created in setup.py with

ext_modules = [
    Extension('pygit2._pygit2', pygit2_exts, **libgit2_kw)
]

seem to get the same parameters in both builds. I checked it with a simple print of the variables.

Where the pygit2._libgit2 extension is built I couldn't find yet. The diff of the two pygit2 modules is mostly identical, especially the relevant places with ._libgit2 or pygit2._libgit2, i.e. ffi.py.

philippun1 commented 9 months ago

I finally figured out that I can just use the prebuilt wheel, which already includes libgit2 with the abi file. So this issue is obsolete.