Python-Imaging in SFOS

In the efforts of making Imageworks easier to maintain and package for harbour and obs I was looking into packaging PIL only to find that it’s actually ‘there’:

Suggests to me I should just be able to use this! I’ve been going this route:
sys.path.append(’/usr/share/harbour-simplecrop/lib/’) and installing a custom version

Does python-imaging in SFOS give me PIL? looks like it.
import PIL
and is it installed by default? looks not.

Seems to be version 8.

1 Like

After a zypper in python3-imaging i can import PIL in python3 on sailfish 4.1.
Most likely you can add it as an require to the yaml and by that it gets added to the spec file as well (something like python3dist(imaging)). Then it should be install together with your package. But i didn’t test that part and it most likely is working for OBS but not allowed in harbour.

Hmmm. Since I’m in harbour now, I’m going to have to do something different. maybe, subdirs builds with copying. that’s how I do c++ libraries (static) + c++ app. hmmm.

Also, I can install python-imaging, but not pything3-imaging.?

Ach, veh. It get’s messier and messier. Recent (8.3.x) versions of PIL include aarch64 bit libs for all dependancies. Sort of classic. In a way, up to 3.4 and pillow 7.2, I’m doing something ‘closer’ to pure in that I’m ‘just copying’ the cpython files (from pypi) to the local lib. The copies of system libs that I do to ‘support that’ is, well, redundant but ‘clean’.

I have no idea how I’m going to do aarch packing with PIL. obviously just building the library separately might do. but not for harbour. sigh.

Why can’t we include python deps for python libs that sfos supplies?

For 4.1 and up you can just use python3-imaging:

The new imageworks packages work. Won’t work SFOS < 4.

In the end, I’m still working around how to build for older versions but the approach I’m taking for the time being, just to show it for others using python libs with c dependancies looks like this;

# >> macros
%define __provides_exclude_from ^%{_datadir}/%{name}/lib/.*\\.so\\>
%define __requires_exclude_from ^%{_datadir}/%{name}/lib/.*\\.so\\>
# << macros

BuildRequires:  python3-imaging


mkdir -p %{buildroot}%{_datadir}/%{name}/lib
cp -ax %{_libdir}/python3.8/site-packages/PIL %{buildroot}%{_datadir}/%{name}/lib/PIL

# >> install post
install -D -t %{buildroot}/%{_datadir}/%{name}/lib/ \
    %{_libdir}/libjpeg.so.62 \
    %{_libdir}/libopenjp2.so.7 \
    %{_libdir}/libtiff.so.5 \
    %{_libdir}/libfreetype.so.6 \
    %{_libdir}/libwebpdemux.so.2 \
    %{_libdir}/libwebpmux.so.3 \
    %{_libdir}/libwebp.so.7
# << install post

This produces a valid install for harbour. Of course it’s a bit much, but it looks like PIL might make it into the list of allowed libraries soon.