MatthiasValvekens / pyHanko

pyHanko: sign and stamp PDF files
MIT License
483 stars 71 forks source link

can't install pyhanko because of uharfbuzz depending on cython #287

Closed cyrilus closed 1 year ago

cyrilus commented 1 year ago

Describe the bug pip install pyhanko fail due to uharfbuzz depending on cython but new release 3.0 break all

To Reproduce pip install pyhanko (I m using alpine)

Expected behavior Error compiling Cython file: 213.2 ------------------------------------------------------------ 213.2 ... 213.2 def guess_segment_properties(self) -> None: 213.2 hb_buffer_guess_segment_properties(self._hb_buffer) 213.2
213.2 def set_message_func(self, callback) -> None: 213.2 self._message_callback = callback 213.2 hb_buffer_set_message_func(self._hb_buffer, msgcallback, <void>callback, NULL) 213.2 ^ 213.2 ------------------------------------------------------------ 213.2
213.2 src/uharfbuzz/_harfbuzz.pyx:371:52: Cannot assign type 'int (hb_buffer_t
, hb_font_t , const char , void *) except? -1' to 'hb_buffer_message_func_t' 213.2
213.2 Error compiling Cython file: 213.2 ------------------------------------------------------------ 213.2 ...

Environment (please complete the following information):

I have make a pull request to uharfbuzz projet but even if they correct this pyhanko still depend on version < 0.36.0 so il won't work

fredericoschardong commented 1 year ago

We are facing the same problem. Had to drop the [opentype] dependency and everything that uses it.

MatthiasValvekens commented 1 year ago

Which Python version are you using? If it's 3.11, I might need to bump uharfbuzz again so you can get prebuilt wheels, but then again I'm not sure whether they build for alpine/musl as well.

So I'm OK with relaxing the upper bound if that helps (although I won't remove it entirely because uharfbuzz occasionally breaks stuff between releases)

fredericoschardong commented 1 year ago

I am using 3.11.

MatthiasValvekens commented 1 year ago

I checked the uharfbuzz release history on PyPI, and apparently 0.35.0 includes prebuilt CPython 3.11 wheels.

There are two complications regarding the Linux wheels:

So if you are using Python 3.7 up till 3.11 on a glibc-based Linux system on an x86_64 architecture, you're good. @cyrilus I know this doesn't include your situation, but how about you, @fredericoschardong?

These complications are still present for 0.37.0, though, so there's no real solution to this problem. However, I highly encourage you to open an issue on the uharfbuzz issue tracker anyway, since I would expect uharfbuzz to still be installable on a musl system (albeit with an extra compilation step, potentially).


In conclusion, this isn't really a pyHanko issue, and as @fredericoschardong pointed out, you're free to not install the [opentype] dependency group (granted, this makes working with non-Latin scripts in signature appearances a royal pain in the butt).

As a matter of general dependency hygiene I will update & retest my dependency bound for uharfbuzz (and try to figure out why dependabot didn't flag it), but the core issue needs to be addressed in uharfbuzz. If and when that happens, I will gladly invest some time in making sure these builds can be used with pyHanko. Unfortunately, that's all I can do, though. :)

MatthiasValvekens commented 1 year ago

Dependabot mystery solved, apparently I only configured it to check for GitHub Actions dependencies, and not Python ones. D'oh. 🤦‍♂️ Either way, pyHanko will keep pace with any potential future uharfbuzz releases that would solve this problem.

MatthiasValvekens commented 1 year ago

Ah, I see now that @cyrilus already filed a bug with uharfbuzz (harfbuzz/uharfbuzz#164) and that they have addressed the issue on their master branch (hence why I didn't see the issue, it was already closed by the time I checked!).

In that case, I'll leave this open until we get a new release from upstream.

fredericoschardong commented 1 year ago

Hi @MatthiasValvekens,

JTLYK, we have a new release of uharfbuzz, namely v0.37.1 with the fix for Cython 3.0.

So if you are using Python 3.7 up till 3.11 on a glibc-based Linux system on an x86_64 architecture, you're good. @cyrilus I know this doesn't include your situation, but how about you, @fredericoschardong?

I am using alpine as well.

I would expect uharfbuzz to still be installable on a musl system (albeit with an extra compilation step, potentially).

Yes, indeed. It builds the wheels, which takes its time. I have opened an issue over at uharfbuzz asking for musl-based wheels.

MatthiasValvekens commented 1 year ago

OK; great news. Since the new upper bound is set at 0.38.0 (Dependabot-managed), I think we can close this one. I'll cut a release as soon as I find the time to do so.

Thanks!