mirror of
https://github.com/kennethreitz-archive/pyinstaller.git
synced 2026-06-05 23:50:17 +00:00
91f816ac46
git-svn-id: http://svn.pyinstaller.org/trunk@698 8dd32b29-ccff-0310-8a9a-9233e24343b1
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
#!/usr/bin/env python
|
|
|
|
def exec_statement(stat):
|
|
"""Executes a Python statement in an externally spawned interpreter, and
|
|
returns anything that was emitted in the standard output as a single string.
|
|
"""
|
|
|
|
import os, tempfile, sys
|
|
|
|
fnm = tempfile.mktemp()
|
|
exe = sys.executable
|
|
|
|
# Using "echo on" as a workaround for a bug in NT4 shell
|
|
if os.name == "nt":
|
|
cmd = '"echo on && "%s" -c "%s" > "%s""' % (exe, stat, fnm)
|
|
else:
|
|
cmd = '"%s" -c "%s" > "%s"' % (exe, stat, fnm)
|
|
os.system(cmd)
|
|
|
|
txt = open(fnm, 'r').read()[:-1]
|
|
os.remove(fnm)
|
|
return txt
|
|
|
|
def qt4_plugins_dir():
|
|
import os
|
|
qt4_plugin_dirs = eval(exec_statement("from PyQt4.QtCore import QCoreApplication; app=QCoreApplication([]); print map(unicode,app.libraryPaths())"))
|
|
if not qt4_plugin_dirs:
|
|
print "E: Cannot find PyQt4 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 PyQt4 plugin directory"
|
|
return ""
|
|
def qt4_phonon_plugins_dir():
|
|
import os
|
|
qt4_plugin_dirs = eval(exec_statement("from PyQt4.QtGui import QApplication; app=QApplication([]); app.setApplicationName('pyinstaller'); from PyQt4.phonon import Phonon; v=Phonon.VideoPlayer(Phonon.VideoCategory); print map(unicode,app.libraryPaths())"))
|
|
if not qt4_plugin_dirs:
|
|
print "E: Cannot find PyQt4 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 PyQt4 phonon plugin directory"
|
|
return ""
|
|
def babel_localedata_dir():
|
|
return exec_statement("import babel.localedata; print babel.localedata._dirname")
|
|
def mpl_data_dir():
|
|
return exec_statement("import matplotlib; print matplotlib._get_data_path()")
|
|
def qwt_numpy_support():
|
|
return eval(exec_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumpy')"))
|
|
def qwt_numeric_support():
|
|
return eval(exec_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumeric')"))
|
|
def qwt_numarray_support():
|
|
return eval(exec_statement("from PyQt4 import Qwt5; print hasattr(Qwt5, 'toNumarray')"))
|