Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2008-06-27 16:16:08
Size: 1895
Editor: GrantEdwards
Comment:
Revision 4 as of 2008-07-08 11:27:43
Size: 1993
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 40: Line 40:
msvcp71.dll, dwmapi.dll to be considered "application" DLLs
instead of "system" DLLs. For any other DLL it returns the
default status as returned by the original isSystemDLL function.
msvcp71.dll and dwmapi.dll to be considered "application" DLLs
instead of "system" DLLs. This should cause py2exe to include them in
the application distribution directory.
For any other DLL it returns the
previous default status as returned by the original isSystemDLL function.

Overriding Criteria for Including DLLs

When py2exe comes across a DLL file that is required by the application, it decides whether or not includes the DLL file in the distribution directory using various criteria. Generally, it doesn't include DLLs if it thinks they belong to the "system" rather than the "application". There is a function that determines whether a specific DLL is a "system" DLL or not. DLLs found in directories like C:\WINNT\system32\MSVCP71.dll aren't included except for a special list of exceptions. If you'd like to override the decision for specific DLL files you can use the hack below in your setup.py file

Example

# setup.py
from distutils.core import setup
import py2exe,sys,os

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
        if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
                return 0
        return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

[remainder of setup.py stuff]

In the example above, we've over-ridden the function py2exe.build_exe.isSystemDLL with our own copy that forces msvcp71.dll and dwmapi.dll to be considered "application" DLLs instead of "system" DLLs. This should cause py2exe to include them in the application distribution directory. For any other DLL it returns the previous default status as returned by the original isSystemDLL function.

Disclaimer

If you use the above mechanism to trick py2exe into distributing any "system" DLLs, check to make sure that you're allowed to distribute those DLLs with your application or else Steve Ballmer [yadda, yadda, yadda] your cat.

OverridingCriteraForIncludingDlls (last edited 2015-01-22 12:39:07 by qqii)