[Python-Dev] [Windows] how to prevent the wrong version of zlib1.dll to be used by lib-dynload modules

Nathaniel Smith njs at pobox.com
Mon Jul 23 13:47:33 EDT 2018


On Mon, Jul 23, 2018, 08:22 Eric Le Lay <contact at elelay.fr> wrote:

> Hello list,
>
> I encountered a problem with the Windows packaging of gPodder[1]
> using msys2:
>
> basic libraries (zlib, openssl) depended upon by python
> platform-specific modules are loaded preferably :
>  1. from lib-dynload (where they are not)
>  2. from the Windows directory (can be any version)
>  3. from the binary directory, next to gpodder.exe (where they are)
>
> So an old zlib1.dll installed by another application in c:\Windows was
> loaded, incompatible with libpng and gPodder couldn't start.
>
> I don't know what's the best approach to solve it:
>  - copy those libraries to lib\pythonxx\lib-dynload (works)
>  - preload them in my main script before they are loaded by the module
>    (works)
>  - patch something in python (dynload_win.c ?) to search first in the
>    executable directory (not tried)
>

The way we avoid these kinds of issues on Linux is to rename included
libraries to unique names (e.g. zlib1-aef3742bc3e.dll), and patch the
extension modules to look for the new names. There's a script (auditwheel)
that does the heavy lifting. On MacOS there's a similar script people use,
called "delocate".

Unfortunately no one has written a script like this for Windows yet. I
think it'd be neat if eventually we could consolidate all this into
auditwheel, but there aren't that many people interested in working on it.
If you wanted to help, the hardest part is already done:
https://github.com/njsmith/machomachomangler/blob/master/README.rst#pe-features

Alternatively if you just want a hack that works quick, I'd do the preload
thing. In general you need to do this anyway, if you don't have all your
extension modules in the same directory. (Unfortunately Windows doesn't
have the equivalent of RPATH.)

-n

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180723/fe5988cb/attachment.html>


More information about the Python-Dev mailing list