kyamagu / skia-python

Python binding to Skia Graphics Library
https://kyamagu.github.io/skia-python/
BSD 3-Clause "New" or "Revised" License
246 stars 43 forks source link

Add support for using system skia #257

Open jopejoe1 opened 3 months ago

jopejoe1 commented 3 months ago

I'm currently working on packaging skia-python for NixOS and i want to compile it against our version of skia. This patch makes it possible for me to-do that.

HinTak commented 3 months ago

No, it does not. I actually do this kind of thing for myself while doing the monthly pulls, and the static libraries needs to be compiled with -rtti, etc. Otherwise it will build and link, but show runtime errors at load time. Convince yourself by actually running your copy of skia-python built your way.

FWIW, my build script to do it separately, and the monthly releases of shared and static libraries, are at: https://github.com/HinTak/skia-building-fun

HinTak commented 3 months ago

And why are you modifying the non-NixOS code, also? You don't need to touch the apple or Windows code, really.

HinTak commented 3 months ago

Just launch python, (into the REPL prompt), then type import skia and see if you can load it.

HinTak commented 3 months ago

I'll let this go through CI, but I am not convinced it will pass... anyway, let's see.

HinTak commented 3 months ago

You'll need a bit more change to setup.py if you use your own libskia, since it inter-depends on freetype / harfbuzz /libjpeg which we bundled in the public wheels. I have the local diff in my private repo, but since it isn't a config usable by a random person who doesn't know how they interdepend, I haven't posted it, nor ever intend to. Anyway, give import skia a try and see if it can convince you not to do this.

jopejoe1 commented 3 months ago

I mainly build it as a dependencies for building noto-font (which did build after this patch), but i did not test it standalone, but doing the import like you said indeed fails with an import error.

ImportError: /nix/store/kc6api80a4zxv2bqyxxk7kxbc9qwsva1-skia-124-unstable-2024-05-22/lib/libsvg.so: undefined symbol: _Z11SkStrSearchPKPKciS0_m

And why are you modifying the non-NixOS code, also? You don't need to touch the apple or Windows code, really.

We also have MacOS support and are working on getting windows support (very early states (mainly cross))

Will need to do a more in dpeth look into this will draft the pr till then.

HinTak commented 3 months ago

import skia (or equivalent from skia import ...) is the first line of any python script using skia-python... so if it doesn't work, it means you mis-built it :-). It is a lesson I learned last summer.