Index: bdist_wininst.py =================================================================== --- bdist_wininst.py (revision 87894) +++ bdist_wininst.py (working copy) @@ -1,8 +1,20 @@ """distutils.command.bdist_wininst Implements the Distutils 'bdist_wininst' command: create a windows installer -exe-program.""" +exe-program. +bdist_wininst produces two types of distributions: +1. binary extension installers +2. pure python code installers + +Installers with binary code can only be produced on Windows system, because +build requires recompilation of extension C code, which can only be made by +the same compiler Python itself is compiled with, i.e. Visual Studio. + +Binary extension installers embed the name of the platform in filename. +Installers with pure Python code always have a "win32" suffix. +""" + __revision__ = "$Id$" import sys @@ -15,7 +27,6 @@ from distutils.dir_util import remove_tree from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils import log -from distutils.util import get_platform class bdist_wininst (Command): @@ -24,8 +35,8 @@ user_options = [('bdist-dir=', None, "temporary directory for creating the distribution"), ('plat-name=', 'p', - "platform name to embed in generated filenames " - "(default: %s)" % get_platform()), + "target platform for C extensions, can be win-amd64, win-ia64 " + "or win32 (default: autodetect)"), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), @@ -63,6 +74,10 @@ def initialize_options (self): self.bdist_dir = None + # supported values for C extensions + # win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)) + # win-ia64 (64bit Windows on Itanium) + # win32 self.plat_name = None self.keep_temp = 0 self.no_target_compile = 0 @@ -116,7 +131,7 @@ def run (self): - if (sys.platform != "win32" and + if (not self.plat_name.startswith("win") and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ @@ -304,15 +319,23 @@ def get_installer_filename(self, fullname): # Factored out to allow overriding in subclasses + + # pure Python packages always have win32 extension + # required for crossplatform behaviour + if (not self.distribution.has_ext_modules() and + not self.distribution.has_c_libraries()): + basename = "%s.%s" % (fullname, "win32") + else: + basename = "%s.%s" % (fullname, self.plat_name) + if self.target_version: # if we create an installer for a specific python version, # it's better to include this in the name installer_name = os.path.join(self.dist_dir, - "%s.%s-py%s.exe" % - (fullname, self.plat_name, self.target_version)) + "%s-py%s.exe" % + (basename, self.target_version)) else: - installer_name = os.path.join(self.dist_dir, - "%s.%s.exe" % (fullname, self.plat_name)) + installer_name = os.path.join(self.dist_dir, "%s.exe" % basename) return installer_name # get_installer_filename()