Py2exe Data_files
Solution 1:
Could it be that matplotlib.get_py2exe_datafiles() isn't returning files in the way that you'd like? What is the output of this?
Perhaps you need to use list() instead, and drop the extra [] around your mpl:
mpl = ('files', list(matplotlib.get_py2exe_datafiles()))
datafiles.append(mpl)
From the docs, this is what the datafiles should look like when you're done:
# data_files specifies a sequence of (directory, files) pairs in the following way:
setup(...,
data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
('config', ['cfg/data.cfg']),
('/etc/init.d', ['init-script'])]
)
Solution 2:
I'm little bit wondering that you want to append the mpl
list to the existing datafiles
one.
Having a look on following py2exe-wiki-help http://www.py2exe.org/index.cgi/MatPlotLib is showing that you have to use directly the list of matpotlib.get_py2exe_datafiles()
import matplotlib
...
setup(
...
data_files=matplotlib.get_py2exe_datafiles(), # <-- here
)
But you append mpl
(a list) to the still existing datafiles
list which will result not in a continuing list but in a matrix:
>>> datafiles = ['<datafile_one>', '<datafile_two>']
>>> mpl = [('files', ['<mpl_file_one>', '<mpl_file_two>', ...])]
>>> print(datafiles.append(mpl)]
['<datafile_one>', '<datafile_two>', [('files', ['<mpl_file_one>', '<mpl_file_two>', ...])]
... and this seems to be not correct.
I guess you want to extend(mpl
) the list of you visual studio dll files (second index slot) in your datafiles list, do you?
[('files', ['<datafile_one>', '<datafile_two>', '<mpl_file_one>', '<mpl_file_two>', ...])]
So finally I think that you should try the following way:
datafiles = glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
datafiles.extend(matplotlib.get_py2exe_datafiles())
...
setup(windows=['main.py'],
data_files= [('files', datafiles)], #<-- important: tuple will be build here finally
...
)
-Colin-
Solution 3:
I managed to do get the following working:
datafiles = [("Microsoft.VC90.CRT", glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
datafiles.extend(matplotlib.get_py2exe_datafiles())
setup(windows=['main.py'], data_files= datafiles, options={"py2exe": {"includes": ["matplotlib"]}})
Thanks for your responses, which pointed me into the right direction!
Post a Comment for "Py2exe Data_files"