Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Set RPATH for pillow.libs dependencies #9198

@WSH032

Description

@WSH032

What did you do?

Strictly speaking, this may not be a pillow issue, but only pillow itself is likely to be able to resolve it, so I'm reporting it here.
Since this is not strictly a Pillow/Python issue, my explanation may not be entirely clear. Please let me know if you need any further information.
I'm not sure if this request is beyond the scope of pillow—if I'm asking for too much, I apologize.

When packaging an embedded python app with pillow dependencies into an AppImage, linuxdeploy reports an error:

https://github.com/pytauri/example-nicegui-app/actions/runs/17540216640/job/49824090673#step:12:1223

Deploying dependencies for ELF file /workspaces/example-nicegui-app/target/bundle-release/bundle/appimage/nicegui-app.AppDir/usr/lib/nicegui-app/lib/python3.13/site-packages/pillow.libs/libxcb-64009ff3.so.1.1.0
ERROR: Could not find dependency: libXau-154567c4.so.6.0.0

As far as I know, linuxdeploy works by using lld to obtain the dynamic library dependencies of ELF files, then copies these libraries into the AppImage and rewrites the original ELF file's RPATH so that it can find these libraries at runtime. This allows the generated AppImage to run on systems without these libraries installed. This is similar to how auditwheel and manylinux wheel work.

After analyzing pillow with readelf and LD_DEBUG=libs, I found the following:

  1. PIL/_imaging is linked to libxcb-64009ff3.so.1.1.0, and since its RPATH is set to $ORIGIN/../pillow.libs, it can correctly find pillow.libs/libxcb-64009ff3.so.1.1.0.

    $ readelf -d pyembed/python/lib/python3.13/site-packages/PIL/_imaging.cpython-313-x86_64-linux-gnu.so
    
    Dynamic section at offset 0x337000 contains 31 entries:
    Tag        Type                         Name/Value
    0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../pillow.libs]
    0x0000000000000001 (NEEDED)             Shared library: [libtiff-13a02c81.so.6.1.0]
    0x0000000000000001 (NEEDED)             Shared library: [libjpeg-8a13c6e0.so.62.4.0]
    0x0000000000000001 (NEEDED)             Shared library: [libopenjp2-56811f71.so.2.5.3]
    0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
    0x0000000000000001 (NEEDED)             Shared library: [libxcb-64009ff3.so.1.1.0]
    0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
    0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
    
  2. libxcb-64009ff3.so.1.1.0 is linked to libXau-154567c4.so.6.0.0, but it does not have an RPATH set, so linuxdeploy cannot find libXau-154567c4.so.6.0.0.

    $ readelf -d pyembed/python/lib/python3.13/site-packages/pillow.libs/libxcb-64009ff3.so.1.1.0
    
    Dynamic section at offset 0x30dc8 contains 26 entries:
    Tag        Type                         Name/Value
    0x0000000000000001 (NEEDED)             Shared library: [libXau-154567c4.so.6.0.0]
    0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
    0x000000000000000e (SONAME)             Library soname: [libxcb-64009ff3.so.1.1.0]
    

You may wonder why libXau-154567c4.so.6.0.0 can be loaded correctly at runtime even though libxcb-64009ff3.so.1.1.0 does not have an RPATH. This is because when loading libXau-154567c4.so.6.0.0, it inherits the RPATH from PIL/_imaging. However, when linuxdeploy processes libxcb-64009ff3.so.1.1.0 individually, it cannot know this.

     59956:     find library=libxcb-64009ff3.so.1.1.0 [0]; searching
     59956:      search path=/workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/../pillow.libs               (RPATH from file /workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/_imaging.cpython-312-x86_64-linux-gnu.so)
     59956:       trying file=/workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/../pillow.libs/libxcb-64009ff3.so.1.1.0

     ...

     59956:     find library=libXau-154567c4.so.6.0.0 [0]; searching
     59956:      search path=/workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/../pillow.libs               (RPATH from file /workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/_imaging.cpython-312-x86_64-linux-gnu.so)
     59956:       trying file=/workspaces/example-nicegui-app/.venv/lib/python3.12/site-packages/PIL/../pillow.libs/libXau-154567c4.so.6.0.0

What did you expect to happen?

Can pillow set the correct RPATH for libraries in pillow.libs so that tools like linuxdeploy can correctly find their dependencies?

It seems pillow uses cibuildwheel to build wheels, so I guess pillow.libs is automatically generated by auditwheel? If that's the case, we can close this issue, since I've already found a similar request in auditwheel: pypa/auditwheel#344.

What are your OS, Python and Pillow versions?

--------------------------------------------------------------------
ubuntu 24.04
Pillow 11.3.0
Python 3.12.1 (main, Jul 10 2025, 11:57:50) [GCC 13.3.0]
--------------------------------------------------------------------
Python executable is /home/codespace/.python/current/bin/python3
System Python files loaded from /home/codespace/.python/current
--------------------------------------------------------------------
Python Pillow modules loaded from /home/codespace/.local/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /home/codespace/.local/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.3.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.5.0
--- AVIF support ok, loaded 1.3.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.1
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.3, compiled for zlib-ng 2.2.4
--- LIBTIFF support ok, loaded 4.7.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.13, harfbuzz 11.2.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions