2828
2929-h: Print this help message.
3030
31+ -w: Toggle Windows (NT or 95) behavior.
32+ (For debugging only -- on a win32 platform, win32 behaviour
33+ is automatic.)
34+
35+ -s subsystem: Specify the subsystem; 'windows' or 'console' (default).
36+ (For Windows only.)
37+
3138Arguments:
3239
3340script.py: The Python script to be executed by the resulting binary.
@@ -76,16 +83,18 @@ def main():
7683 extensions = []
7784 path = sys .path
7885 odir = ''
86+ win = sys .platform [:3 ] == 'win'
7987
8088 # output files
8189 frozen_c = 'frozen.c'
8290 config_c = 'config.c'
8391 target = 'a.out' # normally derived from script name
8492 makefile = 'Makefile'
93+ subsystem = 'console'
8594
8695 # parse command line
8796 try :
88- opts , args = getopt .getopt (sys .argv [1 :], 'he:o:p:P:' )
97+ opts , args = getopt .getopt (sys .argv [1 :], 'he:o:p:P:s:w ' )
8998 except getopt .error , msg :
9099 usage ('getopt error: ' + str (msg ))
91100
@@ -102,6 +111,12 @@ def main():
102111 prefix = a
103112 if o == '-P' :
104113 exec_prefix = a
114+ if o == '-w' :
115+ win = not win
116+ if o == '-s' :
117+ if not win :
118+ usage ("-s subsystem option only on Windows" )
119+ subsystem = a
105120
106121 # default prefix and exec_prefix
107122 if not exec_prefix :
@@ -122,7 +137,7 @@ def main():
122137 binlib = exec_prefix
123138 incldir = os .path .join (prefix , 'Include' )
124139 config_c_in = os .path .join (prefix , 'Modules' , 'config.c.in' )
125- frozenmain_c = os .path .join (prefix , 'Modules ' , 'frozenmain.c' )
140+ frozenmain_c = os .path .join (prefix , 'Python ' , 'frozenmain.c' )
126141 makefile_in = os .path .join (exec_prefix , 'Modules' , 'Makefile' )
127142 else :
128143 binlib = os .path .join (exec_prefix ,
@@ -141,17 +156,22 @@ def main():
141156 usage ('needed directory %s not found' % dir )
142157 if not os .path .isdir (dir ):
143158 usage ('%s: not a directory' % dir )
144- for file in [config_c_in , makefile_in ] + supp_sources :
159+ if win :
160+ files = supp_sources
161+ else :
162+ files = [config_c_in , makefile_in ] + supp_sources
163+ for file in supp_sources :
145164 if not os .path .exists (file ):
146165 usage ('needed file %s not found' % file )
147166 if not os .path .isfile (file ):
148167 usage ('%s: not a plain file' % file )
149- for dir in extensions :
150- setup = os .path .join (dir , 'Setup' )
151- if not os .path .exists (setup ):
152- usage ('needed file %s not found' % setup )
153- if not os .path .isfile (setup ):
154- usage ('%s: not a plain file' % setup )
168+ if not win :
169+ for dir in extensions :
170+ setup = os .path .join (dir , 'Setup' )
171+ if not os .path .exists (setup ):
172+ usage ('needed file %s not found' % setup )
173+ if not os .path .isfile (setup ):
174+ usage ('%s: not a plain file' % setup )
155175
156176 # check that enough arguments are passed
157177 if not args :
@@ -222,6 +242,19 @@ def main():
222242 frozen_c )
223243 os .rename (backup , frozen_c )
224244
245+ if win :
246+ # Taking a shortcut here...
247+ import winmakemakefile
248+ outfp = open (makefile , 'w' )
249+ try :
250+ winmakemakefile .makemakefile (outfp ,
251+ locals (),
252+ [frozenmain_c , frozen_c ],
253+ target )
254+ finally :
255+ outfp .close ()
256+ return
257+
225258 builtins = []
226259 unknown = []
227260 mods = dict .keys ()
0 commit comments