Server: appserver-7f0f8755-nginx-15961cad18524ec5a9db05f2a6a7e440
Current directory: /usr/lib/python2.7/distutils/command
Software: nginx/1.27.5
Shell Command
Create a new file
Upload file
File: bdist_wininst.py
"""distutils.command.bdist_wininst Implements the Distutils 'bdist_wininst' command: create a windows installer exe-program.""" __revision__ = "$Id$" import sys import os import string from sysconfig import get_python_version from distutils.core import Command from distutils.dir_util import remove_tree from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.errors import DistutilsFileError from distutils import log from distutils.util import get_platform class bdist_wininst (Command): description = "create an executable installer for MS Windows" 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()), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), ('target-version=', None, "require a specific python version" + " on the target system"), ('no-target-compile', 'c', "do not compile .py to .pyc on the target system"), ('no-target-optimize', 'o', "do not compile .py to .pyo (optimized)" "on the target system"), ('dist-dir=', 'd', "directory to put final built distributions in"), ('bitmap=', 'b', "bitmap to use for the installer instead of python-powered logo"), ('title=', 't', "title to display on the installer background instead of default"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ('install-script=', None, "basename of installation script to be run after" "installation or before deinstallation"), ('pre-install-script=', None, "Fully qualified filename of a script to be run before " "any files are installed. This script need not be in the " "distribution"), ('user-access-control=', None, "specify Vista's UAC handling - 'none'/default=no " "handling, 'auto'=use UAC if target Python installed for " "all users, 'force'=always use UAC"), ] boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize', 'skip-build'] def initialize_options (self): self.bdist_dir = None self.plat_name = None self.keep_temp = 0 self.no_target_compile = 0 self.no_target_optimize = 0 self.target_version = None self.dist_dir = None self.bitmap = None self.title = None self.skip_build = None self.install_script = None self.pre_install_script = None self.user_access_control = None # initialize_options() def finalize_options (self): self.set_undefined_options('bdist', ('skip_build', 'skip_build')) if self.bdist_dir is None: if self.skip_build and self.plat_name: # If build is skipped and plat_name is overridden, bdist will # not see the correct 'plat_name' - so set that up manually. bdist = self.distribution.get_command_obj('bdist') bdist.plat_name = self.plat_name # next the command will be initialized using that name bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'wininst') if not self.target_version: self.target_version = "" if not self.skip_build and self.distribution.has_ext_modules(): short_version = get_python_version() if self.target_version and self.target_version != short_version: raise DistutilsOptionError, \ "target version can only be %s, or the '--skip-build'" \ " option must be specified" % (short_version,) self.target_version = short_version self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'), ('plat_name', 'plat_name'), ) if self.install_script: for script in self.distribution.scripts: if self.install_script == os.path.basename(script): break else: raise DistutilsOptionError, \ "install_script '%s' not found in scripts" % \ self.install_script # finalize_options() def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform") if not self.skip_build: self.run_command('build') install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir install.skip_build = self.skip_build install.warn_dir = 0 install.plat_name = self.plat_name install_lib = self.reinitialize_command('install_lib') # we do not want to include pyc or pyo files install_lib.compile = 0 install_lib.optimize = 0 if self.distribution.has_ext_modules(): # If we are building an installer for a Python version other # than the one we are currently running, then we need to ensure # our build_lib reflects the other Python version rather than ours. # Note that for target_version!=sys.version, we must have skipped the # build step, so there is no issue with enforcing the build of this # version. target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (self.plat_name, target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier) # Use a custom scheme for the zip-file, because we have to decide # at installation time which scheme to use. for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): value = string.upper(key) if key == 'headers': value = value + '/Include/$dist_name' setattr(install, 'install_' + key, value) log.info("installing to %s", self.bdist_dir) install.ensure_finalized() # avoid warning of 'install_lib' about installing # into a directory not in sys.path sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB')) install.run() del sys.path[0] # And make an archive relative to the root of the # pseudo-installation tree. from tempfile import mktemp archive_basename = mktemp() fullname = self.distribution.get_fullname() arcname = self.make_archive(archive_basename, "zip", root_dir=self.bdist_dir) # create an exe containing the zip-file self.create_exe(arcname, fullname, self.bitmap) if self.distribution.has_ext_modules(): pyversion = get_python_version() else: pyversion = 'any' self.distribution.dist_files.append(('bdist_wininst', pyversion, self.get_installer_filename(fullname))) # remove the zip-file again log.debug("removing temporary file '%s'", arcname) os.remove(arcname) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) # run() def get_inidata (self): # Return data describing the installation. lines = [] metadata = self.distribution.metadata # Write the [metadata] section. lines.append("[metadata]") # 'info' will be displayed in the installer's dialog box, # describing the items to be installed. info = (metadata.long_description or '') + '\n' # Escape newline characters def escape(s): return string.replace(s, "\n", "\\n") for name in ["author", "author_email", "description", "maintainer", "maintainer_email", "name", "url", "version"]: data = getattr(metadata, name, "") if data: info = info + ("\n %s: %s" % \ (string.capitalize(name), escape(data))) lines.append("%s=%s" % (name, escape(data))) # The [setup] section contains entries controlling # the installer runtime. lines.append("\n[Setup]") if self.install_script: lines.append("install_script=%s" % self.install_script) lines.append("info=%s" % escape(info)) lines.append("target_compile=%d" % (not self.no_target_compile)) lines.append("target_optimize=%d" % (not self.no_target_optimize)) if self.target_version: lines.append("target_version=%s" % self.target_version) if self.user_access_control: lines.append("user_access_control=%s" % self.user_access_control) title = self.title or self.distribution.get_fullname() lines.append("title=%s" % escape(title)) import time import distutils build_info = "Built %s with distutils-%s" % \ (time.ctime(time.time()), distutils.__version__) lines.append("build_info=%s" % build_info) return string.join(lines, "\n") # get_inidata() def create_exe (self, arcname, fullname, bitmap=None): import struct self.mkpath(self.dist_dir) cfgdata = self.get_inidata() installer_name = self.get_installer_filename(fullname) self.announce("creating %s" % installer_name) if bitmap: bitmapdata = open(bitmap, "rb").read() bitmaplen = len(bitmapdata) else: bitmaplen = 0 file = open(installer_name, "wb") file.write(self.get_exe_bytes()) if bitmap: file.write(bitmapdata) # Convert cfgdata from unicode to ascii, mbcs encoded try: unicode except NameError: pass else: if isinstance(cfgdata, unicode): cfgdata = cfgdata.encode("mbcs") # Append the pre-install script cfgdata = cfgdata + "\0" if self.pre_install_script: script_data = open(self.pre_install_script, "r").read() cfgdata = cfgdata + script_data + "\n\0" else: # empty pre-install script cfgdata = cfgdata + "\0" file.write(cfgdata) # The 'magic number' 0x1234567B is used to make sure that the # binary layout of 'cfgdata' is what the wininst.exe binary # expects. If the layout changes, increment that number, make # the corresponding changes to the wininst.exe sources, and # recompile them. header = struct.pack("
cur_version: bv = get_build_version() else: if self.target_version < "2.4": bv = 6.0 else: bv = 7.1 else: # for current version - use authoritative check. bv = get_build_version() # wininst-x.y.exe is in the same directory as this file directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? # if plat_name starts with "win" but is not "win32" # we want to strip "win" and leave the rest (e.g. -amd64) # for all other cases, we don't want any suffix if self.plat_name != 'win32' and self.plat_name[:3] == 'win': sfix = self.plat_name[3:] else: sfix = '' filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix)) try: f = open(filename, "rb") except IOError, msg: raise DistutilsFileError, str(msg) + ', %s not included in the Debian packages.' % filename try: return f.read() finally: f.close() # class bdist_wininst
.
47 Items
Change directory
Remove directory
Rename directory
..
58 Items
Change directory
Remove directory
Rename directory
__init__.py
0.8 KB
Edit
Delete
Copy
Move
Remame
__init__.pyc
0.65 KB
Edit
Delete
Copy
Move
Remame
bdist.py
5.46 KB
Edit
Delete
Copy
Move
Remame
bdist.pyc
5.04 KB
Edit
Delete
Copy
Move
Remame
bdist_dumb.py
5.07 KB
Edit
Delete
Copy
Move
Remame
bdist_dumb.pyc
4.85 KB
Edit
Delete
Copy
Move
Remame
bdist_msi.py
34.37 KB
Edit
Delete
Copy
Move
Remame
bdist_msi.pyc
23.36 KB
Edit
Delete
Copy
Move
Remame
bdist_rpm.py
20.55 KB
Edit
Delete
Copy
Move
Remame
bdist_rpm.pyc
17.18 KB
Edit
Delete
Copy
Move
Remame
bdist_wininst.py
14.84 KB
Edit
Delete
Copy
Move
Remame
bdist_wininst.pyc
10.63 KB
Edit
Delete
Copy
Move
Remame
build.py
5.37 KB
Edit
Delete
Copy
Move
Remame
build.pyc
5 KB
Edit
Delete
Copy
Move
Remame
build_clib.py
7.94 KB
Edit
Delete
Copy
Move
Remame
build_clib.pyc
6.18 KB
Edit
Delete
Copy
Move
Remame
build_ext.py
31.53 KB
Edit
Delete
Copy
Move
Remame
build_ext.pyc
18.81 KB
Edit
Delete
Copy
Move
Remame
build_py.py
15.96 KB
Edit
Delete
Copy
Move
Remame
build_py.pyc
11.18 KB
Edit
Delete
Copy
Move
Remame
build_scripts.py
4.49 KB
Edit
Delete
Copy
Move
Remame
build_scripts.pyc
4.36 KB
Edit
Delete
Copy
Move
Remame
check.py
5.44 KB
Edit
Delete
Copy
Move
Remame
check.pyc
6.05 KB
Edit
Delete
Copy
Move
Remame
clean.py
2.75 KB
Edit
Delete
Copy
Move
Remame
clean.pyc
2.99 KB
Edit
Delete
Copy
Move
Remame
command_template
0.7 KB
Edit
Delete
Copy
Move
Remame
config.py
12.82 KB
Edit
Delete
Copy
Move
Remame
config.pyc
12.35 KB
Edit
Delete
Copy
Move
Remame
install.py
27.34 KB
Edit
Delete
Copy
Move
Remame
install.pyc
17.47 KB
Edit
Delete
Copy
Move
Remame
install_data.py
2.78 KB
Edit
Delete
Copy
Move
Remame
install_data.pyc
3.03 KB
Edit
Delete
Copy
Move
Remame
install_egg_info.py
3.51 KB
Edit
Delete
Copy
Move
Remame
install_egg_info.pyc
4.25 KB
Edit
Delete
Copy
Move
Remame
install_headers.py
1.31 KB
Edit
Delete
Copy
Move
Remame
install_headers.pyc
2.19 KB
Edit
Delete
Copy
Move
Remame
install_lib.py
8.14 KB
Edit
Delete
Copy
Move
Remame
install_lib.pyc
6.5 KB
Edit
Delete
Copy
Move
Remame
install_scripts.py
2.02 KB
Edit
Delete
Copy
Move
Remame
install_scripts.pyc
2.85 KB
Edit
Delete
Copy
Move
Remame
register.py
11.56 KB
Edit
Delete
Copy
Move
Remame
register.pyc
9.94 KB
Edit
Delete
Copy
Move
Remame
sdist.py
18.12 KB
Edit
Delete
Copy
Move
Remame
sdist.pyc
16.27 KB
Edit
Delete
Copy
Move
Remame
upload.py
6.88 KB
Edit
Delete
Copy
Move
Remame
upload.pyc
6.16 KB
Edit
Delete
Copy
Move
Remame