Пример #1
0
def hook(mod):
    global hiddenimports
    # `PIL.Image` may be imported as `PIL.Image` or as `Image`
    # (without the prefix). We need to use the same module name to
    # avoid the same module under two different names.
    # We cannot import modules directly in PyInstaller.
    statement = """
import sys
__import__('%(modname)s')
image_mod = sys.modules['%(modname)s']
# PIL uses lazy initialization.
# first import the default stuff ...
image_mod.preinit()
# ... then every available plugin
image_mod.init()
for name in sys.modules:
    if name.endswith('ImagePlugin'):
        # Modules are printed to stdout and the output is then parsed.
        print(name)
""" % {'modname': mod.name}
    out = hookutils.exec_statement(statement)
    mod.add_import = out.strip().splitlines()

    # Ignore 'FixTk' to prevent inclusion of Tcl/Tk library.
    mod.del_import('FixTk')

    return mod
Пример #2
0
def _find_tk_tclshell():
    """
    Get paths to Tcl/Tk from the Tcl shell command 'info library'.

    This command will return path to TCL_LIBRARY.
    On most systems are Tcl and Tk libraries installed
    in the same prefix.
    """
    tcl_root = tk_root = None

    # Python code to get path to TCL_LIBRARY.
    code = 'from %s import Tcl; t = Tcl(); print(t.eval("info library"))' % modname_tkinter

    tcl_root = exec_statement(code)
    tk_version = exec_statement('from _tkinter import TK_VERSION as v; print(v)')
    # TK_LIBRARY is in the same prefix as Tcl.
    tk_root = os.path.join(os.path.dirname(tcl_root), 'tk%s' % tk_version)
    return tcl_root, tk_root
Пример #3
0
def hook(mod):
    statement = """
import os
import gst
reg = gst.registry_get_default()
plug = reg.find_plugin('coreelements')
pth = plug.get_filename()
print(os.path.dirname(pth))
"""
    plugin_path = exec_statement(statement)

    if is_win:
        # TODO Verify that on Windows gst plugins really end with .dll.
        pattern = os.path.join(plugin_path, '*.dll')
    else:
        # Even on OSX plugins end with '.so'.
        pattern = os.path.join(plugin_path, '*.so')

    for f in glob.glob(pattern):
        # 'f' contains absolute path.
        mod.binaries.append((os.path.join('gst_plugins', os.path.basename(f)),
                f, 'BINARY'))

    return mod
Пример #4
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


from PyInstaller.utils.hooks.hookutils import exec_statement

hiddenimports = ["babel.dates"]

babel_localedata_dir = exec_statement(
    "import babel.localedata; print(babel.localedata._dirname)")

datas = [
    (babel_localedata_dir, ""),
]
Пример #5
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


from PyInstaller.utils.hooks.hookutils import exec_statement

mpl_data_dir = exec_statement(
    "import matplotlib; print(matplotlib._get_data_path())")

datas = [
    (mpl_data_dir, ""),
]
Пример #6
0
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


from PyInstaller.utils.hooks.hookutils import exec_statement

# include most common database bindings
# some database bindings are detected and include some
# are not. We should explicitly include database backends.
hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2']

# sqlalchemy.dialects package from 0.6 and newer sqlachemy versions
version = exec_statement('import sqlalchemy; print(sqlalchemy.__version__)')
is_alch06 = version >= '0.6'

if is_alch06:
    dialects = exec_statement("import sqlalchemy.dialects;print(sqlalchemy.dialects.__all__)")
    dialects = eval(dialects.strip())

    for n in dialects:
        hiddenimports.append("sqlalchemy.dialects." + n)
else:
    # sqlalchemy.databases package from pre 0.6 sqlachemy versions
    databases = exec_statement("import sqlalchemy.databases;print(sqlalchemy.databases.__all__)")
    databases = eval(databases.strip())

    for n in databases:
        hiddenimports.append("sqlalchemy.databases." + n)
Пример #7
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


from PyInstaller.utils.hooks.hookutils import exec_statement

# This needed because comtypes wx.lib.activex generates some stuff.
exec_statement("import wx.lib.activex")