[New-bugs-announce] [issue4120] Do not embed manifest files in *.pyd when compiling with MSVC

Andre Heider report at bugs.python.org
Tue Oct 14 10:01:52 CEST 2008

New submission from Andre Heider <a.heider at gom.com>:

The MSVC build process currently embeds the .manifest file, which is
generated by the MS linker, in the following files:

- python.exe
- pythonXY.dll
- *.pyd

The latter is problematic on machines without the MS CRT redistributable
installed (No CRT files in %WINDIR%\WinSxS). While this error won't
occur when the python package is installed, it will in other cases like
in ours:

We use the python interpreter within our application and do ship
python25.dll. We also ship the MS CRT files and place them next to the
main application (MS calls this "private assemblies" and "xcopy
deployment). We do not install the redistributable, because it needs
admin rights.
If a user tries to "import socket" on this setup it will fail, because
the Side by Side / Fusion loader expects the CRT next to the calling
Binary (%PYTHONHOME%\DLLs\_socket.pyd) because of the manifest.

The solution is to not embed the manifest in the *.pyd Modules. This way
the modules just link against msvc*.dll. This works because the windows
loader has already mapped the CRT into memory for the process (either
through python.exe or pythonXY.dll). This is also the only reliable way
i could find to fix the import on machines without redist.

Attached you'll find a patch for the MSVC90 build, apply with -p5. It
will only patch the release file, PCbuild8/pyd_d.vsprops requires the
same fix.

Trolltech also uses this approach for its plugins:

components: Build
files: Python-2.5.2-no.manifest.in.pyd.diff
keywords: patch
messages: 74723
nosy: aheider
severity: normal
status: open
title: Do not embed manifest files in *.pyd when compiling with MSVC
versions: Python 2.5
Added file: http://bugs.python.org/file11783/Python-2.5.2-no.manifest.in.pyd.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list