Kozea / cairocffi

CFFI-based cairo bindings for Python.
https://doc.courtbouillon.org/cairocffi
BSD 3-Clause "New" or "Revised" License
208 stars 54 forks source link

libffi errors after cffi update to 1.15.1 #202

Closed elParaguayo closed 2 years ago

elParaguayo commented 2 years ago

I'm one of the developers for qtile.

We've been seeing errors in the Github CI workflow ever since cffi released version 1.15.1

For example, if we do a cairocffi.ImageSurface.create_from_png call, we're presented with the following error message:

SystemError: ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)

This happens in the CI environment which is running Ubuntu 20.04. I don't see the same error when I run our test suite in an Arch linux container.

While we could pin the cffi version in our test suite, that doesn't feel ideal as we'd expect cairocffi to still work.

I'm not sure what the best way to resolve this issue so would appreciate any guidance you can give.

Thanks!

liZe commented 2 years ago

Hi!

When installed, cairocffi builds the bindings. It looks like the build is done using a version of cffi that’s different from the version you use after.

Could you please share a link to the CI logs, so that I can try to find what’s wrong?

elParaguayo commented 2 years ago

Thanks for the reply.

Based on your comment, there's a good chance that we've done something wrong in setting up our CI and tox environments!

Link to a build failure is here: https://github.com/qtile/qtile/commit/be7aa76573347b9c3bad5f5ffc75c5be62e20498/checks/7256746723/logs

In case that link expires, the workflow page for the failed build is here: https://github.com/qtile/qtile/runs/7256746723?check_suite_focus=true

liZe commented 2 years ago

The problem you have is described in this StackOverflow thread: the cffi wheel includes a ffi library that’s too recent and not compatible with the system library.

It’s not related to cairocffi, only to cffi.

In my opinion, the best solution you have is to follow the first proposed answer: build cffi using the source package, not the wheel (after installing the libffi-dev with apt).

elParaguayo commented 2 years ago

Thank you!

We'll give that a go and report back if there are any issues.

elParaguayo commented 2 years ago

Thanks again. Tests pass with that fix from SO.

FYI we had to pin cffi to 1.15.0 for pypy3.7 because that seems to have a different build of cffi that we can't override.