Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f67c238

Browse files
committed
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.
1 parent 5e70cfe commit f67c238

4 files changed

Lines changed: 62 additions & 7 deletions

File tree

Tools/freeze/checkextensions_win32.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def AddLinkerLib(self, lib):
5454
def GetLinkerLibs(self):
5555
return self.linkerLibs
5656

57-
def checkextensions(unknown, extra_inis):
57+
def checkextensions(unknown, extra_inis, prefix):
5858
# Create a table of frozen extensions
5959

6060
defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini")
@@ -68,7 +68,7 @@ def checkextensions(unknown, extra_inis):
6868
for mod in unknown:
6969
for ini in extra_inis:
7070
# print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...",
71-
defn = get_extension_defn( mod, ini )
71+
defn = get_extension_defn( mod, ini, prefix )
7272
if defn is not None:
7373
# print "Yay - found it!"
7474
ret.append( defn )
@@ -79,8 +79,9 @@ def checkextensions(unknown, extra_inis):
7979

8080
return ret
8181

82-
def get_extension_defn(moduleName, mapFileName):
82+
def get_extension_defn(moduleName, mapFileName, prefix):
8383
if win32api is None: return None
84+
os.environ['PYTHONPREFIX'] = prefix
8485
dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName)
8586
if dsp=="":
8687
return None

Tools/freeze/extensions_win32.ini

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,51 @@
99
; You must ensure that the environment variable PYTHONEX is set
1010
; to point to the root win32 extensions directory
1111

12+
; PYTHONPREFIX must point to the Python build root directory
13+
; (the *parent* of PCbuild); normally the freeze script takes
14+
; care of this.
15+
16+
17+
18+
19+
20+
;--------------------------------------------------------------
21+
;
22+
; Standard Python extension modules
23+
;
24+
25+
; Here are some of the standard Python extensions modules.
26+
; If you need others, add them here
27+
28+
[_socket]
29+
dsp=%PYTHONPREFIX%\PCBuild\_socket.dsp
30+
31+
[_sre]
32+
dsp=%PYTHONPREFIX%\PCBuild\_sre.dsp
33+
34+
[unicodedata]
35+
dsp=%PYTHONPREFIX%\PCBuild\unicodedata.dsp
36+
37+
[mmap]
38+
dsp=%PYTHONPREFIX%\PCBuild\mmap.dsp
39+
40+
[winsound]
41+
dsp=%PYTHONPREFIX%\PCBuild\winsound.dsp
42+
libs=winmm.lib
43+
44+
[parser]
45+
dsp=%PYTHONPREFIX%\PCBuild\parser.dsp
46+
47+
[select]
48+
dsp=%PYTHONPREFIX%\PCBuild\select.dsp
49+
50+
[ucnhash]
51+
dsp=%PYTHONPREFIX%\PCBuild\ucnhash.dsp
52+
53+
[zlib]
54+
dsp=%PYTHONPREFIX%\PCBuild\zlib.dsp
55+
cl=/I %PYTHONPREFIX%\..\zlib113 /D WINDOWS /D _WINDOWS /D ZLIB_DLL /D WIN32
56+
libs=%PYTHONPREFIX%\..\zlib113dll\static32\zlibstat.lib /nodefaultlib:libc
1257

1358
;--------------------------------------------------------------
1459
;
@@ -39,6 +84,10 @@ libs=advapi32.lib
3984
dsp=%PYTHONEX%\win32\win32evtlog.dsp
4085
cl=/I %PYTHONEX%\win32\src
4186

87+
[win32process]
88+
dsp=%PYTHONEX%\win32\win32process.dsp
89+
cl=/I %PYTHONEX%\win32\src
90+
4291
[win32event]
4392
dsp=%PYTHONEX%\win32\win32event.dsp
4493
cl=/I %PYTHONEX%\win32\src
@@ -82,6 +131,10 @@ dsp=%PYTHONEX%\com\win32com.dsp
82131
cl=/I %PYTHONEX%\com\win32com\src\include /I %PYTHONEX%\win32\src
83132
libs=uuid.lib
84133

134+
[win32com.axcontrol.axcontrol]
135+
dsp=%PYTHONEX%\com\axcontrol.dsp
136+
cl=/I %PYTHONEX%\win32\src /I %PYTHONEX%\com\win32com\src\include
137+
85138
[win32com.axscript.axscript]
86139
dsp=%PYTHONEX%\com\Active Scripting.dsp
87140
cl=/I %PYTHONEX%\win32\src /I %PYTHONEX%\com\win32com\src\include

Tools/freeze/freeze.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def main():
112112

113113
# default the exclude list for each platform
114114
if win: exclude = exclude + [
115-
'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2']
115+
'dos', 'dospath', 'mac', 'macpath', 'macfs', 'MACFS', 'posix', 'os2', 'ce']
116116

117117
# modules that are imported by the Python runtime
118118
implicits = ["site", "exceptions"]
@@ -376,7 +376,7 @@ def main():
376376
# Get a list of CExtension instances, each describing a module
377377
# (including its source files)
378378
frozen_extensions = checkextensions_win32.checkextensions(
379-
unknown, extensions)
379+
unknown, extensions, prefix)
380380
for mod in frozen_extensions:
381381
unknown.remove(mod.name)
382382

Tools/freeze/winmakemakefile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def makemakefile(outfp, vars, files, target):
5151
sys.stdout = save
5252

5353
def realwork(vars, moddefns, target):
54+
version_suffix = `sys.version_info[0]`+`sys.version_info[1]`
5455
print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
5556
print
5657
print 'target = %s' % target
@@ -72,7 +73,7 @@ def realwork(vars, moddefns, target):
7273

7374
print '# The following line assumes you have built Python using the standard instructions'
7475
print '# Otherwise fix the following line to point to the library.'
75-
print 'pythonlib = "$(pythonhome)/pcbuild/python15$(debug_suffix).lib"'
76+
print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix
7677
print
7778

7879
# We only ever write one "entry point" symbol - either
@@ -87,7 +88,7 @@ def realwork(vars, moddefns, target):
8788
target_ext = ".dll"
8889

8990

90-
print "# As the target uses Python15.dll, we must use this compiler option!"
91+
print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix
9192
print "cdl = /MD"
9293
print
9394
print "all: $(target)$(debug_suffix)%s" % (target_ext)

0 commit comments

Comments
 (0)