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

Cairocffi not building with XCB support in 1.5.0 #212

Closed elParaguayo closed 1 year ago

elParaguayo commented 1 year ago

I'm one of the qtile developers and I've noticed that our github actions and docs are both failing since the release of 1.5.0.

At first, I thought this was an issue due to both those build environments using Ubuntu 20.04 but switching to 22.04 doesn't change anything. I've also just tried on my laptop and it also fails.

Steps to reproduce:

Start a python terminal:

>>> from cairocffi import cairo
>>> cairo.cairo_xcb_surface_create

This will generate the following error:

AttributeError: cffi library 'libcairo.so.2' has no function, constant or global variable named 'cairo_xcb_surface_create'. Did you mean: 'cairo_pdf_surface_create'?

I can get it to build ok with 1.4.0 so something's stopping it working in 1.5.0.

Happy to help debug this so let me know if there's more information needed.

liZe commented 1 year ago

Thanks for the bug report, and sorry for that. The problem comes from the isolation during the build of the wheel. A dirty workaround is to use:

pip install xcffib wheel
pip install --no-cache --upgrade --no-build-isolation cairocffi

There’s probably a setup option in setuptools to install xcffib before the build, only when the [xcb] option is set.

elParaguayo commented 1 year ago

Thanks for the quick reply. I'll test later today and report back.

I'd also be happy to do a PR to update your docs for this.

liZe commented 1 year ago

I'd also be happy to do a PR to update your docs for this.

Thanks for your help. I’m sure we can find a proper way to handle this in the code.

elParaguayo commented 1 year ago

OK - I'll hold off PR for now but I can confirm the commands in your first reply work for me locally so I'm pretty confident they'll work on our builds once I've updated them.

Thanks for the assistance - greatly appreciated.

liZe commented 1 year ago

We can keep this issue open until a new package is released.

liZe commented 1 year ago

A question has been open: https://github.com/pypa/setuptools/discussions/3873

liZe commented 1 year ago

Version 1.5.1 has been released, tests are welcome!

Malex commented 1 year ago

It was still broken for me when installing qtile (environments: Funtoo and Gentoo, python3.10, etc)

I could resolve it by manually running this command: pip install --no-build-isolation --no-cache --upgrade --ignore-installed cairocffi[xcb]

liZe commented 1 year ago

@Malex Hi!

It doesn’t work anymore for me too. I don’t know why.

During the wheel generation, Setuptools complains that it doesn’t find pip:

Traceback (most recent call last):
  File "/home/lize/venv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'

Even if I add pip as a build dependency, it doesn’t work because the building script doesn’t find the freshly installed xcffib package (the error is silenced by this try, but it doesn’t work).

I don’t know what to do, I’ve already spent days trying to fix this.

Malex commented 1 year ago

Trying to understand why 1.4 worked but 1.5 did not, I took a look at the diffs and there are a few changes that could have impacted https://github.com/Kozea/cairocffi/compare/v1.4.0...v1.5.1 I noticed there is a switch from setup.cfg to pyproject.toml and other related changes. A "solution" could just be to revert this

liZe commented 1 year ago

A "solution" could just be to revert this

I’d like to avoid that, in order to have a future-proof packaging system that follows PEP-517 and PEP-518, but if it’s the only way to get this working, maybe that’s the only solution…

liZe commented 1 year ago

Let’s fix this instead: https://foss.heptapod.net/pypy/cffi/-/issues/441

Anyone interested?

fgplastina commented 1 year ago

i'm getting this error. Tried everything in this thread but didn't work :/

liZe commented 1 year ago

i'm getting this error. Tried everything in this thread but didn't work :/

You can install version 1.4.0 of CairoCFFI.

fgplastina commented 1 year ago

@liZe you are right!

I tried that in the first instance and it didn't work, I just needed to add those arguments to the pip command and specify version 1.4.0. Thanks for your answer!