pythonpy2exe

py2exe data_files


I am trying to build an executable for my python program like so:

from distutils.core import setup
import py2exe, sys, os 
import matplotlib
import numpy
from glob import glob

sys.argv.append('py2exe')

datafiles = [('files', glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]

setup(windows=['main.py'], data_files= datafiles, options={"py2exe": {"includes": ["matplotlib"]}})

This works, however, I need to include these matplotlibfiles obtained by this command as well in order to make the programm work:

matplotlib.get_py2exe_datafiles()

But somehow I am not able to include them into the data_files... I tried stuff like the following, but I am getting errors like "tuple' object has no attribute 'split'"

mpl = [('files', [matplotlib.get_py2exe_datafiles()])]
datafiles.append(mpl)

Also, after compiling the working version without the matplotlibfiles, I get a warning that my project is depending on several other dlls - is there any way to force them all at once into the program?

Thanks for your help!


Solution

  • 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!