Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Provide a clear option to depend on zlib-ng

Open hmaarrfk opened this issue 1 month ago • 5 comments

This is more of a nit than anything, but the problem arose in conda-forge where we still haven't gone all-in on zlib-ng.

As such, we ship BOTH zlib, and zlib-ng, which are designed to co-exist.

I thus wrote a patch for pillow to be able to directly target zlib-ng.

I figured I would upstream it and maybe this can help other distributions with this predicament.

xref:

  • https://github.com/conda-forge/pillow-feedstock/pull/173
  • https://github.com/conda-forge/zlib-ng-feedstock/issues/10
  • https://github.com/conda-forge/conda-forge.github.io/issues/2638

I'm happy to address any issues you all have with this but the idea is that:

if zlib-ng is found, then choose that, and just use the zlib-ng headers directly instead of zlib.h.


TODO:

  • [ ] Add an explicit option to link to prioritize zlib.h or zlib-ng.h -- @mgorny

hmaarrfk avatar Oct 28 '25 00:10 hmaarrfk

I figured I would upstream it and maybe this can help other distributions with this predicament.

Are we the upstream and what is the predicament? 😄

aclark4life avatar Oct 28 '25 00:10 aclark4life

Are we the upstream

I think!? right?

the predicament

Today: i want to take advantage of zlib-ng with Pillow, but:

  1. Either I migrate the whole OS/distribution to zlib-ng
  2. I stick to zlib

I want to have both:

  1. Keep all the old packages on zlib
  2. Use zlib-ng with pillow.

hmaarrfk avatar Oct 28 '25 00:10 hmaarrfk

now if only i understood the windows failures ^_^

hmaarrfk avatar Oct 28 '25 00:10 hmaarrfk

Today: i want to take advantage of zlib-ng with Pillow, but:

  1. Either I migrate the whole OS/distribution to zlib-ng
  2. I stick to zlib

So, just spelling this out, you're saying that if both zlib and zlib-ng are installed, then Pillow may pick zlib over zlib-ng? Probably just based on the order of the paths that it searches?

Have you considered adjusting the search paths? https://pillow.readthedocs.io/en/stable/installation/building-from-source.html#installing

If they are installed in a non-standard location, you may need to configure setuptools to use those locations by editing setup.py or pyproject.toml, or by adding environment variables on the command line:

CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all:

radarhere avatar Oct 28 '25 09:10 radarhere

So, just spelling this out

If you build out zlib and zlib-ng so that they can be co-installed, you have to disable zlib-ng's "compatibility" mode.

Once you've disabled compatibility mode, we are "forced" to use <zlib.h> from zlib.

Have you considered adjusting the search paths?

Yeah this is generally what we do. we set enough flags that it uses the isolated environment.

hmaarrfk avatar Oct 28 '25 11:10 hmaarrfk