From f67c2383da573ecc1a774b61d382ca445d73d37c Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 13 Jul 2000 15:45:17 +0000 Subject: [PATCH] Patch by Toby Dickenson, mentored by Mark Hammond, to support automatically finding (most of) the standard PYD extensions, and to remove the hardcoded Python version. --- Tools/freeze/checkextensions_win32.py | 7 ++-- Tools/freeze/extensions_win32.ini | 53 +++++++++++++++++++++++++++ Tools/freeze/freeze.py | 4 +- Tools/freeze/winmakemakefile.py | 5 ++- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/Tools/freeze/checkextensions_win32.py b/Tools/freeze/checkextensions_win32.py index e3efe05f190..e90bdabb753 100644 --- a/Tools/freeze/checkextensions_win32.py +++ b/Tools/freeze/checkextensions_win32.py @@ -54,7 +54,7 @@ class CExtension: def GetLinkerLibs(self): return self.linkerLibs -def checkextensions(unknown, extra_inis): +def checkextensions(unknown, extra_inis, prefix): # Create a table of frozen extensions defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini") @@ -68,7 +68,7 @@ def checkextensions(unknown, extra_inis): for mod in unknown: for ini in extra_inis: # print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...", - defn = get_extension_defn( mod, ini ) + defn = get_extension_defn( mod, ini, prefix ) if defn is not None: # print "Yay - found it!" ret.append( defn ) @@ -79,8 +79,9 @@ def checkextensions(unknown, extra_inis): return ret -def get_extension_defn(moduleName, mapFileName): +def get_extension_defn(moduleName, mapFileName, prefix): if win32api is None: return None + os.environ['PYTHONPREFIX'] = prefix dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName) if dsp=="": return None diff --git a/Tools/freeze/extensions_win32.ini b/Tools/freeze/extensions_win32.ini index 3b6d08e4976..78f37c8f826 100644 --- a/Tools/freeze/extensions_win32.ini +++ b/Tools/freeze/extensions_win32.ini @@ -9,6 +9,51 @@ ; You must ensure that the environment variable PYTHONEX is set ; to point to the root win32 extensions directory +; PYTHONPREFIX must point to the Python build root directory +; (the *parent* of PCbuild); normally the freeze script takes +; care of this. + + + + + +;-------------------------------------------------------------- +; +; Standard Python extension modules +; + +; Here are some of the standard Python extensions modules. +; If you need others, add them here + +[_socket] +dsp=%PYTHONPREFIX%\PCBuild\_socket.dsp + +[_sre] +dsp=%PYTHONPREFIX%\PCBuild\_sre.dsp + +[unicodedata] +dsp=%PYTHONPREFIX%\PCBuild\unicodedata.dsp + +[mmap] +dsp=%PYTHONPREFIX%\PCBuild\mmap.dsp + +[winsound] +dsp=%PYTHONPREFIX%\PCBuild\winsound.dsp +libs=winmm.lib + +[parser] +dsp=%PYTHONPREFIX%\PCBuild\parser.dsp + +[select] +dsp=%PYTHONPREFIX%\PCBuild\select.dsp + +[ucnhash] +dsp=%PYTHONPREFIX%\PCBuild\ucnhash.dsp + +[zlib] +dsp=%PYTHONPREFIX%\PCBuild\zlib.dsp +cl=/I %PYTHONPREFIX%\..\zlib113 /D WINDOWS /D _WINDOWS /D ZLIB_DLL /D WIN32 +libs=%PYTHONPREFIX%\..\zlib113dll\static32\zlibstat.lib /nodefaultlib:libc ;-------------------------------------------------------------- ; @@ -39,6 +84,10 @@ libs=advapi32.lib dsp=%PYTHONEX%\win32\win32evtlog.dsp cl=/I %PYTHONEX%\win32\src +[win32process] +dsp=%PYTHONEX%\win32\win32process.dsp +cl=/I %PYTHONEX%\win32\src + [win32event] dsp=%PYTHONEX%\win32\win32event.dsp cl=/I %PYTHONEX%\win32\src @@ -82,6 +131,10 @@ dsp=%PYTHONEX%\com\win32com.dsp cl=/I %PYTHONEX%\com\win32com\src\include /I %PYTHONEX%\win32\src libs=uuid.lib +[win32com.axcontrol.axcontrol] +dsp=%PYTHONEX%\com\axcontrol.dsp +cl=/I %PYTHONEX%\win32\src /I %PYTHONEX%\com\win32com\src\include + [win32com.axscript.axscript] dsp=%PYTHONEX%\com\Active Scripting.dsp cl=/I %PYTHONEX%\win32\src /I %PYTHONEX%\com\win32com\src\include diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py index 9502f1b39ba..95f066238bb 100755 --- a/Tools/freeze/freeze.py +++ b/Tools/freeze/freeze.py @@ -112,7 +112,7 @@ def main(): # default the exclude list for each platform if win: exclude = exclude + [ - 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2'] + 'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2', 'ce'] # modules that are imported by the Python runtime implicits = ["site", "exceptions"] @@ -376,7 +376,7 @@ def main(): # Get a list of CExtension instances, each describing a module # (including its source files) frozen_extensions = checkextensions_win32.checkextensions( - unknown, extensions) + unknown, extensions, prefix) for mod in frozen_extensions: unknown.remove(mod.name) diff --git a/Tools/freeze/winmakemakefile.py b/Tools/freeze/winmakemakefile.py index 320504b67e9..d668a6e8273 100644 --- a/Tools/freeze/winmakemakefile.py +++ b/Tools/freeze/winmakemakefile.py @@ -51,6 +51,7 @@ def makemakefile(outfp, vars, files, target): sys.stdout = save def realwork(vars, moddefns, target): + version_suffix = `sys.version_info[0]`+`sys.version_info[1]` print "# Makefile for Microsoft Visual C++ generated by freeze.py script" print print 'target = %s' % target @@ -72,7 +73,7 @@ def realwork(vars, moddefns, target): print '# The following line assumes you have built Python using the standard instructions' print '# Otherwise fix the following line to point to the library.' - print 'pythonlib = "$(pythonhome)/pcbuild/python15$(debug_suffix).lib"' + print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix print # We only ever write one "entry point" symbol - either @@ -87,7 +88,7 @@ def realwork(vars, moddefns, target): target_ext = ".dll" - print "# As the target uses Python15.dll, we must use this compiler option!" + print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix print "cdl = /MD" print print "all: $(target)$(debug_suffix)%s" % (target_ext)