[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

On Mon, Jul 23, 2018 at 2:31 PM, Eric Le Lay <contact at elelay.fr> wrote:
> I encountered a problem with the Windows packaging of gPodder[1]
> using msys2:

Are you using regular Windows Python with msys2, or their custom port?

I installed msys2 and used pacman to install Python 3.6. The msys2
environment names libraries with an "msys-" prefix in the "/usr/bin"
directory, such as msys-python3.6m.dll, msys-readline7.dll, and
msys-z.dll (zlib). This is also the application directory of the msys2
build of Python (i.e. "/usr/bin/python.exe"), so it's the first
directory in the default DLL search path (ahead of system directories
and PATH). Unlike Windows Python, msys2 Python does not use the
alternate search path that replaces the application directory with the
DLL directory in the search path.

A way to implement this that allows multiple versions of a DLL to be
loaded in the same process is to use an assembly that includes the DLL
file in its "<assembly_name>.manifest" file. Add the assembly to the
extension module's #2 manifest (typically embedded, but can be
"<module_name>.2"). The system looks for the "<assembly_name>"
subdirectory in the module directory. In Windows 7+ you can also add a
probing path in a config file (i.e. "<module_name>.config") [1] that
extends the SxS search path with up to 9 relative paths, which can be
up to two levels above the module directory (i.e. "..\..").

[1]: https://docs.microsoft.com/en-us/windows/desktop/SbsCs/application-configuration-files