blob: 959a8bf62ecedab63dc4ec5052ea1215f4bebcab [file] [log] [blame]
Greg Ward27199e82000-06-27 01:24:38 +00001"""distutils.command.bdist_wininst
2
3Implements the Distutils 'bdist_wininst' command: create a windows installer
4exe-program."""
5
Tarek Ziadé36797272010-07-22 12:50:05 +00006import sys, os
Greg Ward27199e82000-06-27 01:24:38 +00007from distutils.core import Command
Tarek Ziadé8b441d02010-01-29 11:46:31 +00008from distutils.util import get_platform
Tarek Ziadé36797272010-07-22 12:50:05 +00009from distutils.dir_util import create_tree, remove_tree
10from distutils.errors import *
11from distutils.sysconfig import get_python_version
12from distutils import log
Greg Ward27199e82000-06-27 01:24:38 +000013
Collin Winter5b7e9d72007-08-30 03:52:21 +000014class bdist_wininst(Command):
Greg Ward27199e82000-06-27 01:24:38 +000015
Greg Wardb0b98a52000-06-28 00:56:20 +000016 description = "create an executable installer for MS Windows"
Greg Ward27199e82000-06-27 01:24:38 +000017
Thomas Heller5c5ea1a2001-03-16 20:57:37 +000018 user_options = [('bdist-dir=', None,
Greg Ward27199e82000-06-27 01:24:38 +000019 "temporary directory for creating the distribution"),
Christian Heimes5e696852008-04-09 08:37:03 +000020 ('plat-name=', 'p',
21 "platform name to embed in generated filenames "
22 "(default: %s)" % get_platform()),
Greg Ward3bfc8c82000-09-16 15:56:32 +000023 ('keep-temp', 'k',
Greg Ward27199e82000-06-27 01:24:38 +000024 "keep the pseudo-installation tree around after " +
25 "creating the distribution archive"),
Thomas Hellera146fea2004-07-06 19:23:27 +000026 ('target-version=', None,
Greg Ward27199e82000-06-27 01:24:38 +000027 "require a specific python version" +
Greg Ward018cbb12000-08-26 02:40:10 +000028 " on the target system"),
Thomas Heller904ca112000-09-07 15:59:22 +000029 ('no-target-compile', 'c',
30 "do not compile .py to .pyc on the target system"),
31 ('no-target-optimize', 'o',
Thomas Heller1dbe9d52000-09-29 11:36:55 +000032 "do not compile .py to .pyo (optimized)"
33 "on the target system"),
Greg Wardfd9f1682000-07-05 03:08:55 +000034 ('dist-dir=', 'd',
35 "directory to put final built distributions in"),
Thomas Hellere09f6392001-02-19 09:20:30 +000036 ('bitmap=', 'b',
37 "bitmap to use for the installer instead of python-powered logo"),
38 ('title=', 't',
39 "title to display on the installer background instead of default"),
Martin v. Löwis9668b932002-01-12 11:27:42 +000040 ('skip-build', None,
41 "skip rebuilding everything (for testing/debugging)"),
Thomas Hellerd2d58e02002-02-20 08:01:19 +000042 ('install-script=', None,
Thomas Hellerd7c14c62002-11-05 10:06:19 +000043 "basename of installation script to be run after"
44 "installation or before deinstallation"),
Thomas Hellera19cdad2004-02-20 14:43:21 +000045 ('pre-install-script=', None,
46 "Fully qualified filename of a script to be run before "
47 "any files are installed. This script need not be in the "
48 "distribution"),
Christian Heimes81ee3ef2008-05-04 22:42:01 +000049 ('user-access-control=', None,
50 "specify Vista's UAC handling - 'none'/default=no "
51 "handling, 'auto'=use UAC if target Python installed for "
52 "all users, 'force'=always use UAC"),
Greg Ward27199e82000-06-27 01:24:38 +000053 ]
54
Andrew M. Kuchlingda9f0bf2002-03-21 23:44:01 +000055 boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
56 'skip-build']
Greg Ward99b032e2000-09-25 01:41:15 +000057
Collin Winter5b7e9d72007-08-30 03:52:21 +000058 def initialize_options(self):
Greg Ward27199e82000-06-27 01:24:38 +000059 self.bdist_dir = None
Christian Heimes5e696852008-04-09 08:37:03 +000060 self.plat_name = None
Greg Ward3bfc8c82000-09-16 15:56:32 +000061 self.keep_temp = 0
Thomas Heller904ca112000-09-07 15:59:22 +000062 self.no_target_compile = 0
63 self.no_target_optimize = 0
Greg Ward27199e82000-06-27 01:24:38 +000064 self.target_version = None
Greg Wardfd9f1682000-07-05 03:08:55 +000065 self.dist_dir = None
Thomas Hellere09f6392001-02-19 09:20:30 +000066 self.bitmap = None
67 self.title = None
Éric Araujofbe37df2011-08-29 21:48:39 +020068 self.skip_build = None
Thomas Hellerd2d58e02002-02-20 08:01:19 +000069 self.install_script = None
Thomas Hellera19cdad2004-02-20 14:43:21 +000070 self.pre_install_script = None
Christian Heimes81ee3ef2008-05-04 22:42:01 +000071 self.user_access_control = None
Greg Ward27199e82000-06-27 01:24:38 +000072
Greg Ward27199e82000-06-27 01:24:38 +000073
Collin Winter5b7e9d72007-08-30 03:52:21 +000074 def finalize_options(self):
Éric Araujofbe37df2011-08-29 21:48:39 +020075 self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
76
Greg Ward27199e82000-06-27 01:24:38 +000077 if self.bdist_dir is None:
Georg Brandlf08a9dd2008-06-10 16:57:31 +000078 if self.skip_build and self.plat_name:
79 # If build is skipped and plat_name is overridden, bdist will
80 # not see the correct 'plat_name' - so set that up manually.
81 bdist = self.distribution.get_command_obj('bdist')
82 bdist.plat_name = self.plat_name
83 # next the command will be initialized using that name
Greg Ward27199e82000-06-27 01:24:38 +000084 bdist_base = self.get_finalized_command('bdist').bdist_base
85 self.bdist_dir = os.path.join(bdist_base, 'wininst')
Éric Araujofbe37df2011-08-29 21:48:39 +020086
Greg Ward27199e82000-06-27 01:24:38 +000087 if not self.target_version:
88 self.target_version = ""
Éric Araujofbe37df2011-08-29 21:48:39 +020089
Thomas Hellera19cdad2004-02-20 14:43:21 +000090 if not self.skip_build and self.distribution.has_ext_modules():
Andrew M. Kuchling1cace1a2002-11-14 01:44:35 +000091 short_version = get_python_version()
Greg Ward27199e82000-06-27 01:24:38 +000092 if self.target_version and self.target_version != short_version:
Collin Winter5b7e9d72007-08-30 03:52:21 +000093 raise DistutilsOptionError(
Georg Brandl56be37c2010-08-02 19:16:34 +000094 "target version can only be %s, or the '--skip-build'" \
Collin Winter5b7e9d72007-08-30 03:52:21 +000095 " option must be specified" % (short_version,))
Greg Ward27199e82000-06-27 01:24:38 +000096 self.target_version = short_version
97
Christian Heimes5e696852008-04-09 08:37:03 +000098 self.set_undefined_options('bdist',
99 ('dist_dir', 'dist_dir'),
100 ('plat_name', 'plat_name'),
101 )
Greg Wardfd9f1682000-07-05 03:08:55 +0000102
Thomas Hellerd7c14c62002-11-05 10:06:19 +0000103 if self.install_script:
104 for script in self.distribution.scripts:
105 if self.install_script == os.path.basename(script):
106 break
107 else:
Collin Winter5b7e9d72007-08-30 03:52:21 +0000108 raise DistutilsOptionError(
109 "install_script '%s' not found in scripts"
110 % self.install_script)
Greg Ward27199e82000-06-27 01:24:38 +0000111
Collin Winter5b7e9d72007-08-30 03:52:21 +0000112 def run(self):
Greg Ward1ac98022000-09-01 01:44:45 +0000113 if (sys.platform != "win32" and
114 (self.distribution.has_ext_modules() or
115 self.distribution.has_c_libraries())):
Thomas Heller904ca112000-09-07 15:59:22 +0000116 raise DistutilsPlatformError \
Greg Ward1ac98022000-09-01 01:44:45 +0000117 ("distribution contains extensions and/or C libraries; "
118 "must be compiled on a Windows 32 platform")
Greg Ward27199e82000-06-27 01:24:38 +0000119
Martin v. Löwis9668b932002-01-12 11:27:42 +0000120 if not self.skip_build:
121 self.run_command('build')
Greg Ward27199e82000-06-27 01:24:38 +0000122
Thomas Hellercd494ad2003-06-12 17:23:58 +0000123 install = self.reinitialize_command('install', reinit_subcommands=1)
Greg Ward27199e82000-06-27 01:24:38 +0000124 install.root = self.bdist_dir
Martin v. Löwis9668b932002-01-12 11:27:42 +0000125 install.skip_build = self.skip_build
Thomas Hellerfd0e82a2002-04-09 14:14:38 +0000126 install.warn_dir = 0
Christian Heimes5e696852008-04-09 08:37:03 +0000127 install.plat_name = self.plat_name
Greg Ward27199e82000-06-27 01:24:38 +0000128
Greg Wardb0b98a52000-06-28 00:56:20 +0000129 install_lib = self.reinitialize_command('install_lib')
Greg Ward018cbb12000-08-26 02:40:10 +0000130 # we do not want to include pyc or pyo files
Greg Ward27199e82000-06-27 01:24:38 +0000131 install_lib.compile = 0
132 install_lib.optimize = 0
Tim Peters182b5ac2004-07-18 06:16:08 +0000133
Mark Hammond79d9bfa2004-10-27 21:54:33 +0000134 if self.distribution.has_ext_modules():
135 # If we are building an installer for a Python version other
136 # than the one we are currently running, then we need to ensure
137 # our build_lib reflects the other Python version rather than ours.
138 # Note that for target_version!=sys.version, we must have skipped the
139 # build step, so there is no issue with enforcing the build of this
140 # version.
141 target_version = self.target_version
142 if not target_version:
143 assert self.skip_build, "Should have already checked this"
144 target_version = sys.version[0:3]
Christian Heimes5e696852008-04-09 08:37:03 +0000145 plat_specifier = ".%s-%s" % (self.plat_name, target_version)
Mark Hammond79d9bfa2004-10-27 21:54:33 +0000146 build = self.get_finalized_command('build')
147 build.build_lib = os.path.join(build.build_base,
148 'lib' + plat_specifier)
Greg Ward27199e82000-06-27 01:24:38 +0000149
Thomas Hellerc010c172001-09-05 13:00:40 +0000150 # Use a custom scheme for the zip-file, because we have to decide
151 # at installation time which scheme to use.
152 for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
Neal Norwitz9d72bb42007-04-17 08:48:32 +0000153 value = key.upper()
Thomas Hellerc010c172001-09-05 13:00:40 +0000154 if key == 'headers':
155 value = value + '/Include/$dist_name'
156 setattr(install,
157 'install_' + key,
158 value)
Greg Ward27199e82000-06-27 01:24:38 +0000159
Jeremy Hyltoncd8a1142002-06-04 20:14:43 +0000160 log.info("installing to %s", self.bdist_dir)
Greg Ward27199e82000-06-27 01:24:38 +0000161 install.ensure_finalized()
Thomas Hellerc010c172001-09-05 13:00:40 +0000162
163 # avoid warning of 'install_lib' about installing
164 # into a directory not in sys.path
165 sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
166
Greg Ward27199e82000-06-27 01:24:38 +0000167 install.run()
168
Thomas Hellerc010c172001-09-05 13:00:40 +0000169 del sys.path[0]
170
Greg Ward27199e82000-06-27 01:24:38 +0000171 # And make an archive relative to the root of the
172 # pseudo-installation tree.
Thomas Hellerd98d25e2002-10-15 14:51:58 +0000173 from tempfile import mktemp
174 archive_basename = mktemp()
Greg Wardfd9f1682000-07-05 03:08:55 +0000175 fullname = self.distribution.get_fullname()
Greg Wardcb1f4c42000-09-30 18:27:54 +0000176 arcname = self.make_archive(archive_basename, "zip",
Thomas Hellerc010c172001-09-05 13:00:40 +0000177 root_dir=self.bdist_dir)
Thomas Hellerc7cb9ed2001-12-18 20:13:40 +0000178 # create an exe containing the zip-file
Thomas Hellere09f6392001-02-19 09:20:30 +0000179 self.create_exe(arcname, fullname, self.bitmap)
Martin v. Löwis98da5622005-03-23 18:54:36 +0000180 if self.distribution.has_ext_modules():
181 pyversion = get_python_version()
182 else:
183 pyversion = 'any'
184 self.distribution.dist_files.append(('bdist_wininst', pyversion,
Martin v. Löwis24ff83d2005-03-22 22:23:29 +0000185 self.get_installer_filename(fullname)))
Thomas Hellerc7cb9ed2001-12-18 20:13:40 +0000186 # remove the zip-file again
Jeremy Hyltoncd8a1142002-06-04 20:14:43 +0000187 log.debug("removing temporary file '%s'", arcname)
Thomas Hellerd98d25e2002-10-15 14:51:58 +0000188 os.remove(arcname)
Greg Ward27199e82000-06-27 01:24:38 +0000189
Greg Ward3bfc8c82000-09-16 15:56:32 +0000190 if not self.keep_temp:
Jeremy Hyltoncd8a1142002-06-04 20:14:43 +0000191 remove_tree(self.bdist_dir, dry_run=self.dry_run)
Greg Ward27199e82000-06-27 01:24:38 +0000192
Collin Winter5b7e9d72007-08-30 03:52:21 +0000193 def get_inidata(self):
Greg Ward1ac98022000-09-01 01:44:45 +0000194 # Return data describing the installation.
Greg Ward1ac98022000-09-01 01:44:45 +0000195 lines = []
Greg Ward27199e82000-06-27 01:24:38 +0000196 metadata = self.distribution.metadata
Greg Ward27199e82000-06-27 01:24:38 +0000197
Thomas Helleree6fd062004-07-23 19:44:29 +0000198 # Write the [metadata] section.
Greg Wardcb1f4c42000-09-30 18:27:54 +0000199 lines.append("[metadata]")
Greg Ward27199e82000-06-27 01:24:38 +0000200
Greg Wardb0b98a52000-06-28 00:56:20 +0000201 # 'info' will be displayed in the installer's dialog box,
202 # describing the items to be installed.
Greg Ward6f9320b2000-08-27 20:44:13 +0000203 info = (metadata.long_description or '') + '\n'
Greg Ward27199e82000-06-27 01:24:38 +0000204
Thomas Helleree6fd062004-07-23 19:44:29 +0000205 # Escape newline characters
206 def escape(s):
Neal Norwitz9d72bb42007-04-17 08:48:32 +0000207 return s.replace("\n", "\\n")
Thomas Helleree6fd062004-07-23 19:44:29 +0000208
Thomas Hellere138f362001-10-05 20:40:48 +0000209 for name in ["author", "author_email", "description", "maintainer",
210 "maintainer_email", "name", "url", "version"]:
211 data = getattr(metadata, name, "")
212 if data:
213 info = info + ("\n %s: %s" % \
Neal Norwitz9d72bb42007-04-17 08:48:32 +0000214 (name.capitalize(), escape(data)))
Thomas Helleree6fd062004-07-23 19:44:29 +0000215 lines.append("%s=%s" % (name, escape(data)))
Greg Ward27199e82000-06-27 01:24:38 +0000216
217 # The [setup] section contains entries controlling
218 # the installer runtime.
Greg Wardcb1f4c42000-09-30 18:27:54 +0000219 lines.append("\n[Setup]")
Thomas Hellerd2d58e02002-02-20 08:01:19 +0000220 if self.install_script:
221 lines.append("install_script=%s" % self.install_script)
Thomas Helleree6fd062004-07-23 19:44:29 +0000222 lines.append("info=%s" % escape(info))
Greg Wardcb1f4c42000-09-30 18:27:54 +0000223 lines.append("target_compile=%d" % (not self.no_target_compile))
224 lines.append("target_optimize=%d" % (not self.no_target_optimize))
Greg Ward27199e82000-06-27 01:24:38 +0000225 if self.target_version:
Greg Wardcb1f4c42000-09-30 18:27:54 +0000226 lines.append("target_version=%s" % self.target_version)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000227 if self.user_access_control:
228 lines.append("user_access_control=%s" % self.user_access_control)
Greg Ward27199e82000-06-27 01:24:38 +0000229
Thomas Hellere09f6392001-02-19 09:20:30 +0000230 title = self.title or self.distribution.get_fullname()
Thomas Helleree6fd062004-07-23 19:44:29 +0000231 lines.append("title=%s" % escape(title))
Thomas Hellerecaf0d82000-09-09 21:15:12 +0000232 import time
233 import distutils
Thomas Hellera19cdad2004-02-20 14:43:21 +0000234 build_info = "Built %s with distutils-%s" % \
Greg Wardcb1f4c42000-09-30 18:27:54 +0000235 (time.ctime(time.time()), distutils.__version__)
236 lines.append("build_info=%s" % build_info)
Neal Norwitz9d72bb42007-04-17 08:48:32 +0000237 return "\n".join(lines)
Greg Ward27199e82000-06-27 01:24:38 +0000238
Collin Winter5b7e9d72007-08-30 03:52:21 +0000239 def create_exe(self, arcname, fullname, bitmap=None):
Greg Ward1ac98022000-09-01 01:44:45 +0000240 import struct
Greg Ward27199e82000-06-27 01:24:38 +0000241
Greg Ward1ac98022000-09-01 01:44:45 +0000242 self.mkpath(self.dist_dir)
243
244 cfgdata = self.get_inidata()
Greg Ward27199e82000-06-27 01:24:38 +0000245
Thomas Heller612eb092004-07-23 19:58:28 +0000246 installer_name = self.get_installer_filename(fullname)
Greg Wardcb1f4c42000-09-30 18:27:54 +0000247 self.announce("creating %s" % installer_name)
Greg Ward27199e82000-06-27 01:24:38 +0000248
Thomas Hellere09f6392001-02-19 09:20:30 +0000249 if bitmap:
250 bitmapdata = open(bitmap, "rb").read()
251 bitmaplen = len(bitmapdata)
252 else:
253 bitmaplen = 0
254
Greg Wardcb1f4c42000-09-30 18:27:54 +0000255 file = open(installer_name, "wb")
256 file.write(self.get_exe_bytes())
Thomas Hellere09f6392001-02-19 09:20:30 +0000257 if bitmap:
258 file.write(bitmapdata)
Fred Drake21d45352001-12-06 21:01:19 +0000259
Thomas Helleree6fd062004-07-23 19:44:29 +0000260 # Convert cfgdata from unicode to ascii, mbcs encoded
Walter Dörwald5de48bd2007-06-11 21:38:39 +0000261 if isinstance(cfgdata, str):
262 cfgdata = cfgdata.encode("mbcs")
Thomas Helleree6fd062004-07-23 19:44:29 +0000263
Thomas Hellera19cdad2004-02-20 14:43:21 +0000264 # Append the pre-install script
Antoine Pitrou1d6a16b2008-09-04 21:32:09 +0000265 cfgdata = cfgdata + b"\0"
Thomas Hellera19cdad2004-02-20 14:43:21 +0000266 if self.pre_install_script:
Antoine Pitrou1d6a16b2008-09-04 21:32:09 +0000267 # We need to normalize newlines, so we open in text mode and
Marc-André Lemburg8f36af72011-02-25 15:42:01 +0000268 # convert back to bytes. "latin-1" simply avoids any possible
Antoine Pitrou1d6a16b2008-09-04 21:32:09 +0000269 # failures.
270 with open(self.pre_install_script, "r",
Marc-André Lemburg8f36af72011-02-25 15:42:01 +0000271 encoding="latin-1") as script:
272 script_data = script.read().encode("latin-1")
Antoine Pitrou1d6a16b2008-09-04 21:32:09 +0000273 cfgdata = cfgdata + script_data + b"\n\0"
Thomas Heller0bc9c912004-02-20 19:38:50 +0000274 else:
275 # empty pre-install script
Antoine Pitrou1d6a16b2008-09-04 21:32:09 +0000276 cfgdata = cfgdata + b"\0"
Greg Wardcb1f4c42000-09-30 18:27:54 +0000277 file.write(cfgdata)
Thomas Hellerb8f134e2004-07-19 09:45:46 +0000278
279 # The 'magic number' 0x1234567B is used to make sure that the
280 # binary layout of 'cfgdata' is what the wininst.exe binary
281 # expects. If the layout changes, increment that number, make
282 # the corresponding changes to the wininst.exe sources, and
283 # recompile them.
Thomas Hellere09f6392001-02-19 09:20:30 +0000284 header = struct.pack("<iii",
Thomas Hellerb8f134e2004-07-19 09:45:46 +0000285 0x1234567B, # tag
Thomas Hellere09f6392001-02-19 09:20:30 +0000286 len(cfgdata), # length
287 bitmaplen, # number of bytes in bitmap
288 )
Greg Wardcb1f4c42000-09-30 18:27:54 +0000289 file.write(header)
290 file.write(open(arcname, "rb").read())
Greg Ward27199e82000-06-27 01:24:38 +0000291
Thomas Heller612eb092004-07-23 19:58:28 +0000292 def get_installer_filename(self, fullname):
293 # Factored out to allow overriding in subclasses
294 if self.target_version:
295 # if we create an installer for a specific python version,
296 # it's better to include this in the name
297 installer_name = os.path.join(self.dist_dir,
Christian Heimes5e696852008-04-09 08:37:03 +0000298 "%s.%s-py%s.exe" %
299 (fullname, self.plat_name, self.target_version))
Thomas Heller612eb092004-07-23 19:58:28 +0000300 else:
301 installer_name = os.path.join(self.dist_dir,
Christian Heimes5e696852008-04-09 08:37:03 +0000302 "%s.%s.exe" % (fullname, self.plat_name))
Thomas Heller30d00082004-08-17 10:15:07 +0000303 return installer_name
Thomas Heller612eb092004-07-23 19:58:28 +0000304
Collin Winter5b7e9d72007-08-30 03:52:21 +0000305 def get_exe_bytes(self):
Thomas Heller0bc9c912004-02-20 19:38:50 +0000306 from distutils.msvccompiler import get_build_version
Thomas Hellera146fea2004-07-06 19:23:27 +0000307 # If a target-version other than the current version has been
308 # specified, then using the MSVC version from *this* build is no good.
309 # Without actually finding and executing the target version and parsing
310 # its sys.version, we just hard-code our knowledge of old versions.
311 # NOTE: Possible alternative is to allow "--target-version" to
312 # specify a Python executable rather than a simple version string.
313 # We can then execute this program to obtain any info we need, such
314 # as the real sys.version string for the build.
315 cur_version = get_python_version()
316 if self.target_version and self.target_version != cur_version:
317 # If the target version is *later* than us, then we assume they
318 # use what we use
319 # string compares seem wrong, but are what sysconfig.py itself uses
320 if self.target_version > cur_version:
321 bv = get_build_version()
322 else:
323 if self.target_version < "2.4":
Christian Heimes5e696852008-04-09 08:37:03 +0000324 bv = 6.0
Thomas Hellera146fea2004-07-06 19:23:27 +0000325 else:
Christian Heimes5e696852008-04-09 08:37:03 +0000326 bv = 7.1
Thomas Hellera146fea2004-07-06 19:23:27 +0000327 else:
328 # for current version - use authoritative check.
329 bv = get_build_version()
330
Thomas Heller0bc9c912004-02-20 19:38:50 +0000331 # wininst-x.y.exe is in the same directory as this file
Thomas Heller450cafa2002-11-22 21:08:34 +0000332 directory = os.path.dirname(__file__)
Thomas Heller0bc9c912004-02-20 19:38:50 +0000333 # we must use a wininst-x.y.exe built with the same C compiler
334 # used for python. XXX What about mingw, borland, and so on?
Tarek Ziadéa6191802009-04-09 22:02:39 +0000335
336 # if plat_name starts with "win" but is not "win32"
337 # we want to strip "win" and leave the rest (e.g. -amd64)
338 # for all other cases, we don't want any suffix
339 if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
340 sfix = self.plat_name[3:]
Christian Heimes5e696852008-04-09 08:37:03 +0000341 else:
Tarek Ziadéa6191802009-04-09 22:02:39 +0000342 sfix = ''
343
Christian Heimes5e696852008-04-09 08:37:03 +0000344 filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
Éric Araujobee5cef2010-11-05 23:51:56 +0000345 f = open(filename, "rb")
346 try:
347 return f.read()
348 finally:
349 f.close()