Hi folks,
I needed to include in my onefile package the library matplotlib
(http://matplotlib.sourceforge.net/)
In order to accomplish this task was necesary to hack a bit.
here are roughly the steps that I did:
1) Create a basic .spec file
>> python Makespec.py --windowed --onefile --paths $paths --out
$destdir --icon $icon $script
You obtain something like
# Specfile
# ------------------------
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
os.path.join(HOMEPATH,'support\\useUnicode.py'),
os.path.join(HOMEPATH,'support\\removeTK.py')],
pathex=['c:\\workspace\\streamerone.client/build/lib.win32-2.4',
'', 'C:\\WINDOWS\\system32\\python24.zip',
'c:\\workspace\\streamerone.client', 'c:\\Python24\\DLLs',
'c:\\Python24\\lib', 'c:\\Python24\\lib\\plat-win',
'c:\\Python24\\lib\\lib-tk', 'c:\\Python24',
'c:\\Python24\\lib\\site-packages',
'c:\\Python24\\lib\\site-packages\\Numeric',
'c:\\Python24\\lib\\site-packages\\win32',
'c:\\Python24\\lib\\site-packages\\win32\\lib',
'c:\\Python24\\lib\\site-packages\\Pythonwin',
'c:\\workspace\\streamerone.client\\pyinstaller'])
pyz = PYZ(a.pure)
import matplotlib
matplotpkg = PKG( Tree(matplotlib._get_data_path()),name='mpl-data.pkg')
exe = EXE(TkPKG(), pyz,matplotpkg,
a.scripts+ [('v', '', 'OPTION')],
a.binaries,
name='streamerone.exe',
debug=True,
strip=False,
upx=False,
console=True ,
icon='c:\\workspace\\streamerone.client\\data\\streamerone.ico')
# unpackMatdata.py
# -------------------------------------------------------
import carchive
import sys
import os
this = carchive.CArchive(sys.executable)
mp = this.openEmbedded('mpl-data.pkg')
targetdir = os.environ['_MEIPASS2']
targetdir = os.path.join(targetdir,'mpl-data')
os.mkdir(targetdir)
os.environ["MATPLOTLIBDATA"] = targetdir
os.putenv("MATPLOTLIBDATA", targetdir)
print "Extracting Matplotlib data ...",
for fnm in mp.contents():
try:
stuff = mp.extract(fnm)[1]
outnm = os.path.join(targetdir, fnm)
dirnm = os.path.dirname(outnm)
if not os.path.exists(dirnm):
os.makedirs(dirnm)
open(outnm, 'wb').write(stuff)
except Exception,mex:
print mex
mp = None
print "ok"
# -------------------------------------------------------
_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller