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. # TODO fix this hook to use attribute 'binaries'. mod.pyinstaller_binaries.append((os.path.join('gst_plugins', os.path.basename(f)), f, 'BINARY')) return mod
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) hiddenimports = out.strip().splitlines() # Ignore 'FixTk' to prevent inclusion of Tcl/Tk library. for i, m in enumerate(mod.pyinstaller_imports): if m[0] == 'FixTk': del mod.pyinstaller_imports[i] break return mod
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) hiddenimports = out.strip().splitlines() # Ignore 'FixTk' to prevent inclusion of Tcl/Tk library. for i, m in enumerate(mod.pyinstaller_imports): if m[0] == 'FixTk': del mod.pyinstaller_imports[i] break return mod
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 Tkinter import Tcl; t = Tcl(); print(t.eval("info library"))' 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
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 Tkinter import Tcl; t = Tcl(); print t.eval("info library")' 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
def qt4_phonon_plugins_dir(): import os qt4_plugin_dirs = eval( exec_statement( "from PySide.QtGui import QApplication; app=QApplication([]); app.setApplicationName('pyinstaller'); from PySide.phonon import Phonon; v=Phonon.VideoPlayer(Phonon.VideoCategory); print map(unicode,app.libraryPaths())" )) if not qt4_plugin_dirs: print "E: Cannot find PySide phonon plugin directories" return "" for d in qt4_plugin_dirs: if os.path.isdir(d): return str(d) # must be 8-bit chars for one-file builds print "E: Cannot find existing PySide phonon plugin directory" return ""
def qt4_phonon_plugins_dir(): import os qt4_plugin_dirs = eval( exec_statement( "from PySide.QtGui import QApplication; app=QApplication([]); app.setApplicationName('pyinstaller'); from PySide.phonon import Phonon; v=Phonon.VideoPlayer(Phonon.VideoCategory); print map(unicode,app.libraryPaths())" ) ) if not qt4_plugin_dirs: print "E: Cannot find PySide phonon plugin directories" return "" for d in qt4_plugin_dirs: if os.path.isdir(d): return str(d) # must be 8-bit chars for one-file builds print "E: Cannot find existing PySide phonon plugin directory" return ""
def hook(mod): # This hook checks for the infamous _xmlcore hack # http://www.amk.ca/diary/2003/03/pythons__xmlplus_hack.html from PyInstaller.hooks.hookutils import exec_statement import marshal txt = exec_statement("import xml; print(xml.__file__)") if txt.find('_xmlplus') > -1: if txt.endswith(".py"): txt = txt + 'c' try: co = marshal.loads(open(txt, 'rb').read()[8:]) except IOError: co = compile(open(txt[:-1], 'rU').read(), txt, 'exec') old_pth = mod.__path__[:] mod.__init__('xml', txt, co) mod.__path__.extend(old_pth) return mod
def hook(mod): # This hook checks for the infamous _xmlcore hack # http://www.amk.ca/diary/2003/03/pythons__xmlplus_hack.html from PyInstaller.hooks.hookutils import exec_statement import marshal txt = exec_statement("import xml; print(xml.__file__)") if txt.find("_xmlplus") > -1: if txt.endswith(".py"): txt = txt + "c" try: co = marshal.loads(open(txt, "rb").read()[8:]) except IOError: co = compile(open(txt[:-1], "rU").read(), txt, "exec") old_pth = mod.__path__[:] mod.__init__("xml", txt, co) mod.__path__.extend(old_pth) return mod
#----------------------------------------------------------------------------- # 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.hooks.hookutils import exec_statement # This needed because comtypes wx.lib.activex generates some stuff. exec_statement("import wx.lib.activex")
#----------------------------------------------------------------------------- # 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. #----------------------------------------------------------------------------- import os from PyInstaller.hooks.hookutils import exec_statement template_path = exec_statement('from pyexcelerate.Writer import _TEMPLATE_PATH as tp; print(tp)') datas = [ (os.path.join(template_path, '*'), os.path.join('pyexcelerate', 'templates')) ]
from PyInstaller.hooks.hookutils import exec_statement mpl_data_dir = exec_statement( "import matplotlib; print matplotlib._get_data_path()") datas = [ (mpl_data_dir, ""), ]
#----------------------------------------------------------------------------- # 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.hooks.hookutils import exec_statement hiddenimports = ["babel.dates"] babel_localedata_dir = exec_statement( "import babel.localedata; print babel.localedata._dirname") datas = [ (babel_localedata_dir, ""), ]
#----------------------------------------------------------------------------- # 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. #----------------------------------------------------------------------------- import os from PyInstaller.hooks.hookutils import exec_statement template_path = exec_statement('from pyexcelerate.Writer import _TEMPLATE_PATH as tp; print tp') datas = [ (os.path.join(template_path, '*'), os.path.join('pyexcelerate', 'templates')) ]
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Contributed by Greg Copeland from PyInstaller.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.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) # 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 databases: hiddenimports.append("sqlalchemy.dialects." + n)
# 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.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.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) # 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 databases: hiddenimports.append("sqlalchemy.dialects." + n)
from PyInstaller.hooks.hookutils import exec_statement hiddenimports = ["babel.dates"] babel_localedata_dir = exec_statement( "import babel.localedata; print babel.localedata._dirname") datas = [ (babel_localedata_dir, ""), ]
#----------------------------------------------------------------------------- # 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.hooks.hookutils import exec_statement mpl_data_dir = exec_statement( "import matplotlib; print(matplotlib._get_data_path())") datas = [ (mpl_data_dir, ""), ]
from PyInstaller.hooks.hookutils import exec_statement exec_statement("import wx.lib.activex") #this needed because comtypes wx.lib.activex generates some stuff
from PyInstaller.hooks.hookutils import exec_statement exec_statement( "import wx.lib.activex" ) #this needed because comtypes wx.lib.activex generates some stuff