1 from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
4 class bdist_wininst(_bdist_wininst):
5 _good_upload = _bad_upload = None
7 def create_exe(self, arcname, fullname, bitmap=None):
8 _bdist_wininst.create_exe(self, arcname, fullname, bitmap)
9 installer_name = self.get_installer_filename(fullname)
10 if self.target_version:
11 pyversion = self.target_version
12 # fix 2.5+ bdist_wininst ignoring --target-version spec
13 self._bad_upload = ('bdist_wininst', 'any', installer_name)
16 self._good_upload = ('bdist_wininst', pyversion, installer_name)
18 def _fix_upload_names(self):
19 good, bad = self._good_upload, self._bad_upload
20 dist_files = getattr(self.distribution, 'dist_files', [])
22 dist_files.remove(bad)
23 if good not in dist_files:
24 dist_files.append(good)
26 def reinitialize_command (self, command, reinit_subcommands=0):
27 cmd = self.distribution.reinitialize_command(
28 command, reinit_subcommands)
29 if command in ('install', 'install_lib'):
30 cmd.install_lib = None # work around distutils bug
34 self._is_running = True
36 _bdist_wininst.run(self)
37 self._fix_upload_names()
39 self._is_running = False
42 if not hasattr(_bdist_wininst, 'get_installer_filename'):
43 def get_installer_filename(self, fullname):
44 # Factored out to allow overriding in subclasses
45 if self.target_version:
46 # if we create an installer for a specific python version,
47 # it's better to include this in the name
48 installer_name = os.path.join(self.dist_dir,
50 (fullname, self.target_version))
52 installer_name = os.path.join(self.dist_dir,
53 "%s.win32.exe" % fullname)
55 # get_installer_filename()