コード例 #1
0
ファイル: hook-_tkinter.py プロジェクト: bitlogik/guardata
def _collect_tcl_tk_files(hook_api):
    """
    Get a list of TOC-style 3-tuples describing all external Tcl/Tk data files.

    Returns
    -------
    Tree
        Such list.
    """

    tcl_root, tk_root = _find_tcl_tk(hook_api)

    # TODO Shouldn't these be fatal exceptions?
    if not tcl_root:
        logger.error("Tcl/Tk improperly installed on this system.")
        return []
    if not os.path.isdir(tcl_root):
        logger.error('Tcl data directory "%s" not found.', tcl_root)
        return []
    if not os.path.isdir(tk_root):
        logger.error('Tk data directory "%s" not found.', tk_root)
        return []

    tcltree = Tree(tcl_root, prefix="tcl", excludes=["demos", "*.lib", "tclConfig.sh"])
    tktree = Tree(tk_root, prefix="tk", excludes=["demos", "*.lib", "tkConfig.sh"])

    # If the current Tcl installation is a Teapot-distributed version of
    # ActiveTcl and the current platform is OS X, warn that this is bad.
    if is_darwin:
        _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree)

    return tcltree + tktree
コード例 #2
0
ファイル: tcl_tk.py プロジェクト: Doringber/blog
def collect_tcl_tk_files(tkinter_ext_file):
    """
    Get a list of TOC-style 3-tuples describing all external Tcl/Tk data files.

    Returns
    -------
    Tree
        Such list.
    """
    # Find Tcl and Tk data directory by analyzing the _tkinter extension.
    tcl_root, tk_root = _find_tcl_tk(tkinter_ext_file)

    # On macOS, we do not collect system libraries. Therefore, if system
    # Tcl/Tk framework is used, it makes no sense to collect its data,
    # either. In this case, _find_tcl_tk() will return None, None - either
    # deliberately (we found the data paths, but ignore them) or not
    # (starting with macOS 11, the data path cannot be found until shared
    # library discovery is fixed).
    if compat.is_darwin and not tcl_root and not tk_root:
        logger.info('Not collecting Tcl/Tk data - either python is using '
                    'macOS\' system Tcl/Tk framework, or Tcl/Tk data '
                    'directories could not be found.')
        return []

    # TODO Shouldn't these be fatal exceptions?
    if not tcl_root:
        logger.error('Tcl/Tk improperly installed on this system.')
        return []
    if not os.path.isdir(tcl_root):
        logger.error('Tcl data directory "%s" not found.', tcl_root)
        return []
    if not os.path.isdir(tk_root):
        logger.error('Tk data directory "%s" not found.', tk_root)
        return []

    tcltree = Tree(tcl_root,
                   prefix='tcl',
                   excludes=['demos', '*.lib', 'tclConfig.sh'])
    tktree = Tree(tk_root,
                  prefix='tk',
                  excludes=['demos', '*.lib', 'tkConfig.sh'])

    # If the current Tcl installation is a Teapot-distributed version of
    # ActiveTcl and the current platform is OS X, warn that this is bad.
    if compat.is_darwin:
        _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree)

    # Collect Tcl modules
    tclmodulestree = _collect_tcl_modules(tcl_root)

    return (tcltree + tktree + tclmodulestree)
コード例 #3
0
def _collect_tcl_modules(tcl_root):
    """
    Get a list of TOC-style 3-tuples describing Tcl modules. The modules
    directory is separate from the library/data one, and is located
    at $tcl_root/../tclX, where X is the major Tcl version.

    Returns
    -------
    Tree
        Such list, if the modules directory exists.
    """

    # Obtain Tcl major version.
    tcl_version = exec_statement(
        'from tkinter import Tcl; print(Tcl().eval("info tclversion"))')
    tcl_version = tcl_version.split('.')[0]

    modules_dirname = 'tcl' + str(tcl_version)
    modules_path = os.path.join(tcl_root, '..', modules_dirname)

    if not os.path.isdir(modules_path):
        logger.warn('Tcl modules directory %s does not exist.', modules_path)
        return []

    return Tree(modules_path, prefix=modules_dirname)
コード例 #4
0
def _collect_tcl_tk_files(hook_api):
    """
    Get a list of TOC-style 3-tuples describing all external Tcl/Tk data files.

    Returns
    -------
    Tree
        Such list.
    """
    # Workaround for broken Tcl/Tk detection in virtualenv on Windows.
    _handle_broken_tcl_tk()

    tcl_root, tk_root = _find_tcl_tk(hook_api)

    # TODO Shouldn't these be fatal exceptions?
    if not tcl_root:
        logger.error('Tcl/Tk improperly installed on this system.')
        return []
    if not os.path.isdir(tcl_root):
        logger.error('Tcl data directory "%s" not found.', tcl_root)
        return []
    if not os.path.isdir(tk_root):
        logger.error('Tk data directory "%s" not found.', tk_root)
        return []

    # The following lines are edited by ON 050218
    # according to https://github.com/viotti/pyinstaller/commit/597af5cb01c064620b53ea1ee537e30f56fa481d
    tcltree = Tree(
        #tcl_root, prefix='tcl', excludes=['demos', '*.lib', 'tclConfig.sh'])
        tcl_root,
        prefix='tclResources',
        excludes=['demos', '*.lib', 'tclConfig.sh'])
    tktree = Tree(
        #tk_root, prefix='tk', excludes=['demos', '*.lib', 'tkConfig.sh'])
        tk_root,
        prefix='tkResources',
        excludes=['demos', '*.lib', 'tkConfig.sh'])

    # If the current Tcl installation is a Teapot-distributed version of
    # ActiveTcl and the current platform is OS X, warn that this is bad.
    if is_darwin:
        _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree)

    return (tcltree + tktree)
コード例 #5
0
def _collect_tcl_tk_files(hook_api):
    """
    Get a list of TOC-style 3-tuples describing all external Tcl/Tk data files.

    Returns
    -------
    Tree
        Such list.
    """
    # Workaround for broken Tcl/Tk detection in virtualenv on Windows.
    _handle_broken_tcl_tk()

    tcl_root, tk_root = _find_tcl_tk(hook_api)

    # TODO Shouldn't these be fatal exceptions?
    if not tcl_root:
        logger.error('Tcl/Tk improperly installed on this system.')
        return []
    if not os.path.isdir(tcl_root):
        logger.error('Tcl data directory "%s" not found.', tcl_root)
        return []
    if not os.path.isdir(tk_root):
        logger.error('Tk data directory "%s" not found.', tk_root)
        return []

    tcltree = Tree(tcl_root,
                   prefix='tcl',
                   excludes=['demos', '*.lib', 'tclConfig.sh'])
    tktree = Tree(tk_root,
                  prefix='tk',
                  excludes=['demos', '*.lib', 'tkConfig.sh'])

    # If the current Tcl installation is a Teapot-distributed version of
    # ActiveTcl and the current platform is OS X, warn that this is bad.
    if is_darwin:
        _warn_if_activetcl_or_teapot_installed(tcl_root, tcltree)

    return (tcltree + tktree)
コード例 #6
0
 def make_datas_toc(self):
     toc = TOC((x, y, 'DATA') for x, y in self._datas)
     for dist in self._distributions:
         if (dist._pyinstaller_info['egg']
                 and not dist._pyinstaller_info['zipped']
                 and not dist._pyinstaller_info['zip-safe']):
             # this is a un-zipped, not-zip-safe egg
             toplevel = dist.get_metadata('top_level.txt').strip()
             basedir = dist.location
             if toplevel:
                 os.path.join(basedir, toplevel)
             tree = Tree(dist.location, excludes=PY_IGNORE_EXTENSIONS)
             toc.extend(tree)
     return toc
コード例 #7
0
 def __collect_data_files_from_zip(zipfilename):
     # 'PyInstaller.config' cannot be imported as other top-level modules.
     from PyInstaller.config import CONF
     workpath = os.path.join(CONF['workpath'],
                             os.path.basename(zipfilename))
     try:
         os.makedirs(workpath)
     except OSError as e:
         import errno
         if e.errno != errno.EEXIST:
             raise
     # TODO: extract only those file which would then be included
     with zipfile.ZipFile(zipfilename) as zfh:
         zfh.extractall(workpath)
     return Tree(workpath, excludes=PY_IGNORE_EXTENSIONS)
コード例 #8
0
 def make_zipped_data_toc(self):
     toc = TOC()
     logger.debug('Looking for egg data files...')
     for dist in self._distributions:
         if dist._pyinstaller_info['egg']:
             # TODO: check in docs if top_level.txt always exists
             toplevel = dist.get_metadata('top_level.txt').strip()
             if dist._pyinstaller_info['zipped']:
                 # this is a zipped egg
                 tree = self.__collect_data_files_from_zip(dist.location)
                 toc.extend(tree)
             elif dist._pyinstaller_info['zip-safe']:
                 # this is an un-zipped, zip-safe egg
                 basedir = dist.location
                 if toplevel:
                     os.path.join(basedir, toplevel)
                 tree = Tree(dist.location, excludes=PY_IGNORE_EXTENSIONS)
                 toc.extend(tree)
             else:
                 # this is an un-zipped, not-zip-safe egg, handled in make_datas_toc()
                 pass
     return toc