當前位置: 首頁>>代碼示例>>Python>>正文


Python datastruct.Target類代碼示例

本文整理匯總了Python中PyInstaller.building.datastruct.Target的典型用法代碼示例。如果您正苦於以下問題:Python Target類的具體用法?Python Target怎麽用?Python Target使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Target類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, *tocs, **kwargs):
        """
        tocs
                One or more TOCs (Tables of Contents), normally an
                Analysis.pure.

                If this TOC has an attribute `_code_cache`, this is
                expected to be a dict of module code objects from
                ModuleGraph.

        kwargs
            Possible keywork arguments:

            name
                A filename for the .pyz. Normally not needed, as the generated
                name will do fine.
            cipher
                The block cipher that will be used to encrypt Python bytecode.

        """

        from ..config import CONF
        Target.__init__(self)
        name = kwargs.get('name', None)
        cipher = kwargs.get('cipher', None)
        self.toc = TOC()
        # If available, use code objects directly from ModuleGraph to
        # speed up PyInstaller.
        self.code_dict = {}
        for t in tocs:
            self.toc.extend(t)
            self.code_dict.update(getattr(t, '_code_cache', {}))

        # Paths to remove from filenames embedded in code objects
        self.replace_paths = sys.path + CONF['pathex']
        # Make sure paths end with os.sep
        self.replace_paths = [os.path.join(f, '') for f in self.replace_paths]

        self.name = name
        if name is None:
            self.name = os.path.splitext(self.tocfilename)[0] + '.pyz'
        # PyInstaller bootstrapping modules.
        self.dependencies = get_bootstrap_modules()
        # Bundle the crypto key.
        self.cipher = cipher
        if cipher:
            key_file = ('pyimod00_crypto_key',
                         os.path.join(CONF['workpath'], 'pyimod00_crypto_key.pyc'),
                         'PYMODULE')
            # Insert the key as the first module in the list. The key module contains
            # just variables and does not depend on other modules.
            self.dependencies.insert(0, key_file)
        # Compile the top-level modules so that they end up in the CArchive and can be
        # imported by the bootstrap script.
        self.dependencies = misc.compile_py_files(self.dependencies, CONF['workpath'])
        self.__postinit__()
開發者ID:Bluehorn,項目名稱:pyinstaller,代碼行數:56,代碼來源:api.py

示例2: _check_guts

    def _check_guts(self, data, last_build):
        if not os.path.exists(self.name):
            logger.info("Rebuilding %s because %s missing",
                        self.tocbasename, os.path.basename(self.name))
            return 1
        if not self.append_pkg and not os.path.exists(self.pkgname):
            logger.info("Rebuilding because %s missing",
                        os.path.basename(self.pkgname))
            return 1

        if Target._check_guts(self, data, last_build):
            return True

        if (data['versrsrc'] or data['resources']) and not is_win:
            # todo: really ignore :-)
            logger.warn('ignoring version, manifest and resources, platform not capable')
        if data['icon'] and not (is_win or is_darwin):
            logger.warn('ignoring icon, platform not capable')

        mtm = data['mtm']
        if mtm != misc.mtime(self.name):
            logger.info("Rebuilding %s because mtimes don't match", self.tocbasename)
            return True
        if mtm < misc.mtime(self.pkg.tocfilename):
            logger.info("Rebuilding %s because pkg is more recent", self.tocbasename)
            return True
        return False
開發者ID:cbgp,項目名稱:diyabc,代碼行數:27,代碼來源:api.py

示例3: __init__

    def __init__(self, *args, **kws):
        """
        args
                One or more arguments that are either TOCs Targets.
        kws
            Possible keywork arguments:

                name
                    The name of the directory to be built.
        """
        from ..config import CONF
        Target.__init__(self)
        self.strip_binaries = kws.get('strip', False)
        self.console = True

        if CONF['hasUPX']:
            self.upx_binaries = kws.get('upx', False)
        else:
            self.upx_binaries = False

        self.name = kws.get('name')
        # Old .spec format included in 'name' the path where to collect files
        # for the created app.
        # app. New format includes only directory name.
        #
        # The 'name' directory is created in DISTPATH and necessary files are
        # then collected to this directory.
        self.name = os.path.join(CONF['distpath'], os.path.basename(self.name))

        self.toc = TOC()
        for arg in args:
            if isinstance(arg, TOC):
                self.toc.extend(arg)
            elif isinstance(arg, Target):
                self.toc.append((os.path.basename(arg.name), arg.name, arg.typ))
                if isinstance(arg, EXE):
                    self.console = arg.console
                    for tocnm, fnm, typ in arg.toc:
                        if tocnm == os.path.basename(arg.name) + ".manifest":
                            self.toc.append((tocnm, fnm, typ))
                    if not arg.append_pkg:
                        self.toc.append((os.path.basename(arg.pkgname), arg.pkgname, 'PKG'))
                self.toc.extend(arg.dependencies)
            else:
                self.toc.extend(arg)
        self.__postinit__()
開發者ID:pyinstaller,項目名稱:pyinstaller,代碼行數:46,代碼來源:api.py

示例4: __init__

 def __init__(self, toc, name=None, cdict=None, exclude_binaries=0,
              strip_binaries=False, upx_binaries=False):
     """
     toc
             A TOC (Table of Contents)
     name
             An optional filename for the PKG.
     cdict
             Dictionary that specifies compression by typecode. For Example,
             PYZ is left uncompressed so that it can be accessed inside the
             PKG. The default uses sensible values. If zlib is not available,
             no compression is used.
     exclude_binaries
             If True, EXTENSIONs and BINARYs will be left out of the PKG,
             and forwarded to its container (usually a COLLECT).
     strip_binaries
             If True, use 'strip' command to reduce the size of binary files.
     upx_binaries
     """
     Target.__init__(self)
     self.toc = toc
     self.cdict = cdict
     self.name = name
     if name is None:
         self.name = os.path.splitext(self.tocfilename)[0] + '.pkg'
     self.exclude_binaries = exclude_binaries
     self.strip_binaries = strip_binaries
     self.upx_binaries = upx_binaries
     # This dict tells PyInstaller what items embedded in the executable should
     # be compressed.
     if self.cdict is None:
         self.cdict = {'EXTENSION': COMPRESSED,
                       'DATA': COMPRESSED,
                       'BINARY': COMPRESSED,
                       'EXECUTABLE': COMPRESSED,
                       'PYSOURCE': COMPRESSED,
                       'PYMODULE': COMPRESSED,
                       # Do not compress PYZ as a whole. Single modules are
                       # compressed when creating PYZ archive.
                       'PYZ': UNCOMPRESSED}
     self.__postinit__()
開發者ID:cbgp,項目名稱:diyabc,代碼行數:41,代碼來源:api.py


注:本文中的PyInstaller.building.datastruct.Target類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。