@@ -63,6 +63,12 @@ def finalize_options (self):
6363
6464
6565 def run (self ):
66+ if (sys .platform != "win32" and
67+ (self .distribution .has_ext_modules () or
68+ self .distribution .has_c_libraries ())):
69+ raise DistutilsPlatformError , \
70+ ("distribution contains extensions and/or C libraries; "
71+ "must be compiled on a Windows 32 platform" )
6672
6773 self .run_command ('build' )
6874
@@ -103,21 +109,16 @@ def run (self):
103109
104110 # run()
105111
106- def create_inifile (self ):
107- # Create an inifile containing data describing the installation.
108- # This could be done without creating a real file, but
109- # a file is (at least) useful for debugging bdist_wininst.
112+ def get_inidata (self ):
113+ # Return data describing the installation.
110114
115+ lines = []
111116 metadata = self .distribution .metadata
112- ini_name = "%s.ini" % metadata .get_fullname ()
113-
114- self .announce ("creating %s" % ini_name )
115- inifile = open (ini_name , "w" )
116117
117118 # Write the [metadata] section. Values are written with
118119 # repr()[1:-1], so they do not contain unprintable characters, and
119120 # are not surrounded by quote chars.
120- inifile . write ("[metadata]\n " )
121+ lines . append ("[metadata]" )
121122
122123 # 'info' will be displayed in the installer's dialog box,
123124 # describing the items to be installed.
@@ -129,27 +130,28 @@ def create_inifile (self):
129130 if data :
130131 info = info + ("\n %s: %s" % \
131132 (string .capitalize (name ), data ))
132- inifile . write ("%s=%s\n " % (name , repr (data )[1 :- 1 ]))
133+ lines . append ("%s=%s" % (name , repr (data )[1 :- 1 ]))
133134
134135 # The [setup] section contains entries controlling
135136 # the installer runtime.
136- inifile . write ("\n [Setup]\n " )
137- inifile . write ("info=%s\n " % repr (info )[1 :- 1 ])
138- inifile . write ("pthname=%s.%s\n " % (metadata .name , metadata .version ))
137+ lines . append ("\n [Setup]" )
138+ lines . append ("info=%s" % repr (info )[1 :- 1 ])
139+ lines . append ("pthname=%s.%s" % (metadata .name , metadata .version ))
139140 if self .target_version :
140- inifile . write ("target_version=%s\n " % self .target_version )
141+ lines . append ("target_version=%s" % self .target_version )
141142
142143 title = self .distribution .get_fullname ()
143- inifile .write ("title=%s\n " % repr (title )[1 :- 1 ])
144- inifile .close ()
145- return ini_name
144+ lines .append ("title=%s" % repr (title )[1 :- 1 ])
145+ return string .join (lines , "\n " )
146146
147- # create_inifile ()
147+ # get_inidata ()
148148
149149 def create_exe (self , arcname , fullname ):
150- import struct #, zlib
150+ import struct
151+
152+ self .mkpath (self .dist_dir )
151153
152- cfgdata = open ( self .create_inifile ()). read ()
154+ cfgdata = self .get_inidata ()
153155
154156 installer_name = os .path .join (self .dist_dir ,
155157 "%s.win32.exe" % fullname )
0 commit comments