Use patched version of zlib-ng to fix install name by freakboy3742 · Pull Request #8743 · python-pillow/Pillow

Fixes #8671. Alternative to #8672 and #8673

When zlib-ng is compiled on macOS, it sets the install name of the libz.1.dylib to @rpath/libz.1.dylib. This means that any subsequent load requires a valid DYLD_LIBRARY_PATH to resolve the link.

Recent versions of macOS have a feature called System Integrity Protection (SIP) which (amongst other things) prevents DYLD_LIBRARY_PATH from being passed into subshells. As the build's dependencies aren't on the default library path on macOS, delocate-wheel is unable to resolve the libz library.

SIP is disabled on GitHub Actions configurations, so this problem isn't seen in CI; but is enabled by default on macOS machines, so individual developers building Pillow dependencies will get an error from cibuildwheel when the wheel is repaired.

This PR uses the PATCH_DIR mechanism provided by multibuild to provide a patch for zlib-ng (authored by @radarhere, submitted upstream as zlib-ng/zlib-ng#1867) to fix the issue with zlib-ng's install dir during the original build.

This is an alternative to:

I'd argue this is the best of the three approaches, as it fixes the root problem at the source, in a way that will (eventually) require no patch at all.