← All tasks
pythonpython-pillow/Pillow #8671Not a task: not reproduced

Delocate error when building Pillow on macOS

envgap__python-pillow__Pillow-8671

01 / FAILURE SIGNATURE

As reported upstream

ERROR:delocate.libsana:
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
b57b4e5f2c3c3996aa8c8b774842c6037a957937
Manifest
pyproject.toml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

python-pillow/Pillow #8671 · read the original issue
### What did you do?



When trying to build macOS wheels with cibuildwheel on a personal machine, an error is raised during the delocate step.



### What did you expect to happen?



A cibuildwheel build should successfully complete.



### What actually happened?

```console

$ CIBW_ARCHS=arm64 cibuildwheel

...

(logs of build of dependencies and the unrepaired Pillow wheel redacted)

...

Repairing wheel...



+ delocate-wheel --require-archs arm64 -w /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/repaired_wheel -v /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/built_wheel/pillow-11.2.0.dev0-cp39-cp39-macosx_11_0_arm64.whl

Fixing: /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/built_wheel/pillow-11.2.0.dev0-cp39-cp39-macosx_11_0_arm64.whl

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libfreetype.6.dylib

  Search path:

    

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libpng16.16.dylib

  Search path:

    

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libpng16.16.dylib

  Search path:

    

ERROR:delocate.libsana:@rpath/libz.1.dylib not found, requested by /Users/rkm/projects/pillow/build/deps/darwin/lib/libpng16.16.dylib

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libfreetype.6.dylib

  Search path:

    

ERROR:delocate.libsana:@rpath/libz.1.dylib not found, requested by /Users/rkm/projects/pillow/build/deps/darwin/lib/libfreetype.6.dylib

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/tmp8h0w3b6k/wheel/PIL/_imaging.cpython-39-darwin.so

  Search path:

    

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libtiff.6.dylib

  Search path:

    

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /Users/rkm/projects/pillow/build/deps/darwin/lib/libtiff.6.dylib

  Search path:

    

ERROR:delocate.libsana:@rpath/libz.1.dylib not found, requested by /Users/rkm/projects/pillow/build/deps/darwin/lib/libtiff.6.dylib

ERROR:delocate.libsana:

@rpath/libz.1.dylib not found:

  Needed by: /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/tmp8h0w3b6k/wheel/PIL/_imaging.cpython-39-darwin.so

  Search path:

    

ERROR:delocate.libsana:@rpath/libz.1.dylib not found, requested by /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/tmp8h0w3b6k/wheel/PIL/_imaging.cpython-39-darwin.so

Traceback (most recent call last):

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/bin/delocate-wheel", line 8, in <module>

    sys.exit(main())

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/lib/python3.9/site-packages/delocate/cmd/delocate_wheel.py", line 116, in main

    copied = delocate_wheel(

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/lib/python3.9/site-packages/delocate/delocating.py", line 1057, in delocate_wheel

    copied_libs = delocate_path(

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/lib/python3.9/site-packages/delocate/delocating.py", line 511, in delocate_path

    lib_dict = tree_libs_from_directory(

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/lib/python3.9/site-packages/delocate/libsana.py", line 377, in tree_libs_from_directory

    return _tree_libs_from_libraries(

  File "/private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/build/venv/lib/python3.9/site-packages/delocate/libsana.py", line 320, in _tree_libs_from_libraries

    raise DelocationError("Could not find all dependencies.")

delocate.libsana.DelocationError: Could not find all dependencies.



                                                              ✕ 5.22s

Error: Command delocate-wheel --require-archs arm64 -w /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/repaired_wheel -v /private/var/folders/b_/khqk71xd45d049kxc_59ltp80000gn/T/cibw-run-_1yd3ael/cp39-macosx_arm64/built_wheel/pillow-11.2.0.dev0-cp39-cp39-macosx_11_0_arm64.whl failed with code 1. 



```



### What are your OS, Python and Pillow versions?



* OS: macOS 15.2, 14.7

* Python: 3.9, 3.12

* Pillow: 11.1+; main (github hash 24863610)



### Additional details



The problem appears to have been caused by the introduction of zlib-ng. On my 2 test machines, the compiled version of this library has an `install_name` of `@rpath/libz.1.dylib`. This is fine, but it requires that `DYLD_LIBRARY_PATH` includes the build dependencies path. 



When cibuildwheel invokes `delocate-wheel`, `DYLD_LIBRARY_PATH` is set to include the build dependencies lib directory. However, `delocate-wheel` is invoked with `shell()`, and macOS does not pass `DYLD_LIBRARY_PATH` to child subprocesses. 



All the other binary dependencies appear to be compiled with absolute paths in the `install_name`.



This clearly isn't an issue with CI, as wheel builds are succeeding there. However, I can't work out *why* they are succeeding. I can only assume that there is something on the CI machine that puts a `libz.1.dylib` compatible library on the linking path which is able to satisfy delocate.



I've been able to work around the issue locally by manually rewriting the install name of libz.dylib after the build-zlib-ng completes (there doesn't appear to be a compilation option to explicitly guarantee an absolute install_name). However, it's not clear to me if I've missed something obvious in my setup, or if this is an issue that others are likely to see.

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]