本文整理汇总了Python中PyInstaller.building.datastruct.Target.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Target.__init__方法的具体用法?Python Target.__init__怎么用?Python Target.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyInstaller.building.datastruct.Target
的用法示例。
在下文中一共展示了Target.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyInstaller.building.datastruct import Target [as 别名]
# 或者: from PyInstaller.building.datastruct.Target import __init__ [as 别名]
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__()
示例2: __init__
# 需要导入模块: from PyInstaller.building.datastruct import Target [as 别名]
# 或者: from PyInstaller.building.datastruct.Target import __init__ [as 别名]
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__()
示例3: __init__
# 需要导入模块: from PyInstaller.building.datastruct import Target [as 别名]
# 或者: from PyInstaller.building.datastruct.Target import __init__ [as 别名]
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__()