Skip to content

Conversation

@hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Oct 28, 2025

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:

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

@aclark4life
Copy link
Member

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? 😄

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Oct 28, 2025

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
Copy link
Contributor Author

now if only i understood the windows failures ^_^

@radarhere
Copy link
Member

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:

@hmaarrfk
Copy link
Contributor Author

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.

if feature.want("zlib"):
_dbg("Looking for zlib")
if _find_include_file(self, "zlib.h"):
if _find_include_file(self, "zlib-ng.h"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces an automagic dependency on zlib-ng when both zlib-ng and zlib are installed. As such, Gentoo (as well as anyone who doesn't build in an entirely isolated environment) would end up having to patch this out in order to use plain zlib. I'm not opposed to having zlib-ng as an option, but then it should be an option, one that can be explicitly disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for bringing this up. it is true. it is "priority for zlib-ng".

I'm happy to add an explicit "switch" between the two.

I'll add that to the todo list if the general strategy is agreeable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working on the general strategy being agreeable. That is usually determined by interest and the number of folks looking for a fix for this issue. At present, we depend on zlib and zlib-ng satisfies that dependency via compat mode. How many folks are looking for co-existence ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s a good question.

I’m. Happy to let this PR sit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants