]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/bdist_wininst.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / command / bdist_wininst.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/bdist_wininst.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/bdist_wininst.py
deleted file mode 100644 (file)
index 518b298..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-"""distutils.command.bdist_wininst\r
-\r
-Implements the Distutils 'bdist_wininst' command: create a windows installer\r
-exe-program."""\r
-\r
-__revision__ = "$Id$"\r
-\r
-import sys\r
-import os\r
-import string\r
-\r
-from sysconfig import get_python_version\r
-\r
-from distutils.core import Command\r
-from distutils.dir_util import remove_tree\r
-from distutils.errors import DistutilsOptionError, DistutilsPlatformError\r
-from distutils import log\r
-from distutils.util import get_platform\r
-\r
-class bdist_wininst (Command):\r
-\r
-    description = "create an executable installer for MS Windows"\r
-\r
-    user_options = [('bdist-dir=', None,\r
-                     "temporary directory for creating the distribution"),\r
-                    ('plat-name=', 'p',\r
-                     "platform name to embed in generated filenames "\r
-                     "(default: %s)" % get_platform()),\r
-                    ('keep-temp', 'k',\r
-                     "keep the pseudo-installation tree around after " +\r
-                     "creating the distribution archive"),\r
-                    ('target-version=', None,\r
-                     "require a specific python version" +\r
-                     " on the target system"),\r
-                    ('no-target-compile', 'c',\r
-                     "do not compile .py to .pyc on the target system"),\r
-                    ('no-target-optimize', 'o',\r
-                     "do not compile .py to .pyo (optimized)"\r
-                     "on the target system"),\r
-                    ('dist-dir=', 'd',\r
-                     "directory to put final built distributions in"),\r
-                    ('bitmap=', 'b',\r
-                     "bitmap to use for the installer instead of python-powered logo"),\r
-                    ('title=', 't',\r
-                     "title to display on the installer background instead of default"),\r
-                    ('skip-build', None,\r
-                     "skip rebuilding everything (for testing/debugging)"),\r
-                    ('install-script=', None,\r
-                     "basename of installation script to be run after"\r
-                     "installation or before deinstallation"),\r
-                    ('pre-install-script=', None,\r
-                     "Fully qualified filename of a script to be run before "\r
-                     "any files are installed.  This script need not be in the "\r
-                     "distribution"),\r
-                    ('user-access-control=', None,\r
-                     "specify Vista's UAC handling - 'none'/default=no "\r
-                     "handling, 'auto'=use UAC if target Python installed for "\r
-                     "all users, 'force'=always use UAC"),\r
-                   ]\r
-\r
-    boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',\r
-                       'skip-build']\r
-\r
-    def initialize_options (self):\r
-        self.bdist_dir = None\r
-        self.plat_name = None\r
-        self.keep_temp = 0\r
-        self.no_target_compile = 0\r
-        self.no_target_optimize = 0\r
-        self.target_version = None\r
-        self.dist_dir = None\r
-        self.bitmap = None\r
-        self.title = None\r
-        self.skip_build = 0\r
-        self.install_script = None\r
-        self.pre_install_script = None\r
-        self.user_access_control = None\r
-\r
-    # initialize_options()\r
-\r
-\r
-    def finalize_options (self):\r
-        if self.bdist_dir is None:\r
-            if self.skip_build and self.plat_name:\r
-                # If build is skipped and plat_name is overridden, bdist will\r
-                # not see the correct 'plat_name' - so set that up manually.\r
-                bdist = self.distribution.get_command_obj('bdist')\r
-                bdist.plat_name = self.plat_name\r
-                # next the command will be initialized using that name\r
-            bdist_base = self.get_finalized_command('bdist').bdist_base\r
-            self.bdist_dir = os.path.join(bdist_base, 'wininst')\r
-        if not self.target_version:\r
-            self.target_version = ""\r
-        if not self.skip_build and self.distribution.has_ext_modules():\r
-            short_version = get_python_version()\r
-            if self.target_version and self.target_version != short_version:\r
-                raise DistutilsOptionError, \\r
-                      "target version can only be %s, or the '--skip-build'" \\r
-                      " option must be specified" % (short_version,)\r
-            self.target_version = short_version\r
-\r
-        self.set_undefined_options('bdist',\r
-                                   ('dist_dir', 'dist_dir'),\r
-                                   ('plat_name', 'plat_name'),\r
-                                  )\r
-\r
-        if self.install_script:\r
-            for script in self.distribution.scripts:\r
-                if self.install_script == os.path.basename(script):\r
-                    break\r
-            else:\r
-                raise DistutilsOptionError, \\r
-                      "install_script '%s' not found in scripts" % \\r
-                      self.install_script\r
-    # finalize_options()\r
-\r
-\r
-    def run (self):\r
-        if (sys.platform != "win32" and\r
-            (self.distribution.has_ext_modules() or\r
-             self.distribution.has_c_libraries())):\r
-            raise DistutilsPlatformError \\r
-                  ("distribution contains extensions and/or C libraries; "\r
-                   "must be compiled on a Windows 32 platform")\r
-\r
-        if not self.skip_build:\r
-            self.run_command('build')\r
-\r
-        install = self.reinitialize_command('install', reinit_subcommands=1)\r
-        install.root = self.bdist_dir\r
-        install.skip_build = self.skip_build\r
-        install.warn_dir = 0\r
-        install.plat_name = self.plat_name\r
-\r
-        install_lib = self.reinitialize_command('install_lib')\r
-        # we do not want to include pyc or pyo files\r
-        install_lib.compile = 0\r
-        install_lib.optimize = 0\r
-\r
-        if self.distribution.has_ext_modules():\r
-            # If we are building an installer for a Python version other\r
-            # than the one we are currently running, then we need to ensure\r
-            # our build_lib reflects the other Python version rather than ours.\r
-            # Note that for target_version!=sys.version, we must have skipped the\r
-            # build step, so there is no issue with enforcing the build of this\r
-            # version.\r
-            target_version = self.target_version\r
-            if not target_version:\r
-                assert self.skip_build, "Should have already checked this"\r
-                target_version = sys.version[0:3]\r
-            plat_specifier = ".%s-%s" % (self.plat_name, target_version)\r
-            build = self.get_finalized_command('build')\r
-            build.build_lib = os.path.join(build.build_base,\r
-                                           'lib' + plat_specifier)\r
-\r
-        # Use a custom scheme for the zip-file, because we have to decide\r
-        # at installation time which scheme to use.\r
-        for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):\r
-            value = string.upper(key)\r
-            if key == 'headers':\r
-                value = value + '/Include/$dist_name'\r
-            setattr(install,\r
-                    'install_' + key,\r
-                    value)\r
-\r
-        log.info("installing to %s", self.bdist_dir)\r
-        install.ensure_finalized()\r
-\r
-        # avoid warning of 'install_lib' about installing\r
-        # into a directory not in sys.path\r
-        sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))\r
-\r
-        install.run()\r
-\r
-        del sys.path[0]\r
-\r
-        # And make an archive relative to the root of the\r
-        # pseudo-installation tree.\r
-        from tempfile import mktemp\r
-        archive_basename = mktemp()\r
-        fullname = self.distribution.get_fullname()\r
-        arcname = self.make_archive(archive_basename, "zip",\r
-                                    root_dir=self.bdist_dir)\r
-        # create an exe containing the zip-file\r
-        self.create_exe(arcname, fullname, self.bitmap)\r
-        if self.distribution.has_ext_modules():\r
-            pyversion = get_python_version()\r
-        else:\r
-            pyversion = 'any'\r
-        self.distribution.dist_files.append(('bdist_wininst', pyversion,\r
-                                             self.get_installer_filename(fullname)))\r
-        # remove the zip-file again\r
-        log.debug("removing temporary file '%s'", arcname)\r
-        os.remove(arcname)\r
-\r
-        if not self.keep_temp:\r
-            remove_tree(self.bdist_dir, dry_run=self.dry_run)\r
-\r
-    # run()\r
-\r
-    def get_inidata (self):\r
-        # Return data describing the installation.\r
-\r
-        lines = []\r
-        metadata = self.distribution.metadata\r
-\r
-        # Write the [metadata] section.\r
-        lines.append("[metadata]")\r
-\r
-        # 'info' will be displayed in the installer's dialog box,\r
-        # describing the items to be installed.\r
-        info = (metadata.long_description or '') + '\n'\r
-\r
-        # Escape newline characters\r
-        def escape(s):\r
-            return string.replace(s, "\n", "\\n")\r
-\r
-        for name in ["author", "author_email", "description", "maintainer",\r
-                     "maintainer_email", "name", "url", "version"]:\r
-            data = getattr(metadata, name, "")\r
-            if data:\r
-                info = info + ("\n    %s: %s" % \\r
-                               (string.capitalize(name), escape(data)))\r
-                lines.append("%s=%s" % (name, escape(data)))\r
-\r
-        # The [setup] section contains entries controlling\r
-        # the installer runtime.\r
-        lines.append("\n[Setup]")\r
-        if self.install_script:\r
-            lines.append("install_script=%s" % self.install_script)\r
-        lines.append("info=%s" % escape(info))\r
-        lines.append("target_compile=%d" % (not self.no_target_compile))\r
-        lines.append("target_optimize=%d" % (not self.no_target_optimize))\r
-        if self.target_version:\r
-            lines.append("target_version=%s" % self.target_version)\r
-        if self.user_access_control:\r
-            lines.append("user_access_control=%s" % self.user_access_control)\r
-\r
-        title = self.title or self.distribution.get_fullname()\r
-        lines.append("title=%s" % escape(title))\r
-        import time\r
-        import distutils\r
-        build_info = "Built %s with distutils-%s" % \\r
-                     (time.ctime(time.time()), distutils.__version__)\r
-        lines.append("build_info=%s" % build_info)\r
-        return string.join(lines, "\n")\r
-\r
-    # get_inidata()\r
-\r
-    def create_exe (self, arcname, fullname, bitmap=None):\r
-        import struct\r
-\r
-        self.mkpath(self.dist_dir)\r
-\r
-        cfgdata = self.get_inidata()\r
-\r
-        installer_name = self.get_installer_filename(fullname)\r
-        self.announce("creating %s" % installer_name)\r
-\r
-        if bitmap:\r
-            bitmapdata = open(bitmap, "rb").read()\r
-            bitmaplen = len(bitmapdata)\r
-        else:\r
-            bitmaplen = 0\r
-\r
-        file = open(installer_name, "wb")\r
-        file.write(self.get_exe_bytes())\r
-        if bitmap:\r
-            file.write(bitmapdata)\r
-\r
-        # Convert cfgdata from unicode to ascii, mbcs encoded\r
-        try:\r
-            unicode\r
-        except NameError:\r
-            pass\r
-        else:\r
-            if isinstance(cfgdata, unicode):\r
-                cfgdata = cfgdata.encode("mbcs")\r
-\r
-        # Append the pre-install script\r
-        cfgdata = cfgdata + "\0"\r
-        if self.pre_install_script:\r
-            script_data = open(self.pre_install_script, "r").read()\r
-            cfgdata = cfgdata + script_data + "\n\0"\r
-        else:\r
-            # empty pre-install script\r
-            cfgdata = cfgdata + "\0"\r
-        file.write(cfgdata)\r
-\r
-        # The 'magic number' 0x1234567B is used to make sure that the\r
-        # binary layout of 'cfgdata' is what the wininst.exe binary\r
-        # expects.  If the layout changes, increment that number, make\r
-        # the corresponding changes to the wininst.exe sources, and\r
-        # recompile them.\r
-        header = struct.pack("<iii",\r
-                             0x1234567B,       # tag\r
-                             len(cfgdata),     # length\r
-                             bitmaplen,        # number of bytes in bitmap\r
-                             )\r
-        file.write(header)\r
-        file.write(open(arcname, "rb").read())\r
-\r
-    # create_exe()\r
-\r
-    def get_installer_filename(self, fullname):\r
-        # Factored out to allow overriding in subclasses\r
-        if self.target_version:\r
-            # if we create an installer for a specific python version,\r
-            # it's better to include this in the name\r
-            installer_name = os.path.join(self.dist_dir,\r
-                                          "%s.%s-py%s.exe" %\r
-                                           (fullname, self.plat_name, self.target_version))\r
-        else:\r
-            installer_name = os.path.join(self.dist_dir,\r
-                                          "%s.%s.exe" % (fullname, self.plat_name))\r
-        return installer_name\r
-    # get_installer_filename()\r
-\r
-    def get_exe_bytes (self):\r
-        from distutils.msvccompiler import get_build_version\r
-        # If a target-version other than the current version has been\r
-        # specified, then using the MSVC version from *this* build is no good.\r
-        # Without actually finding and executing the target version and parsing\r
-        # its sys.version, we just hard-code our knowledge of old versions.\r
-        # NOTE: Possible alternative is to allow "--target-version" to\r
-        # specify a Python executable rather than a simple version string.\r
-        # We can then execute this program to obtain any info we need, such\r
-        # as the real sys.version string for the build.\r
-        cur_version = get_python_version()\r
-        if self.target_version and self.target_version != cur_version:\r
-            # If the target version is *later* than us, then we assume they\r
-            # use what we use\r
-            # string compares seem wrong, but are what sysconfig.py itself uses\r
-            if self.target_version > cur_version:\r
-                bv = get_build_version()\r
-            else:\r
-                if self.target_version < "2.4":\r
-                    bv = 6.0\r
-                else:\r
-                    bv = 7.1\r
-        else:\r
-            # for current version - use authoritative check.\r
-            bv = get_build_version()\r
-\r
-        # wininst-x.y.exe is in the same directory as this file\r
-        directory = os.path.dirname(__file__)\r
-        # we must use a wininst-x.y.exe built with the same C compiler\r
-        # used for python.  XXX What about mingw, borland, and so on?\r
-\r
-        # if plat_name starts with "win" but is not "win32"\r
-        # we want to strip "win" and leave the rest (e.g. -amd64)\r
-        # for all other cases, we don't want any suffix\r
-        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':\r
-            sfix = self.plat_name[3:]\r
-        else:\r
-            sfix = ''\r
-\r
-        filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))\r
-        f = open(filename, "rb")\r
-        try:\r
-            return f.read()\r
-        finally:\r
-            f.close()\r
-# class bdist_wininst\r