I was having trouble with py2exe not getting the datafiles that it needed. I
noticed someone else got it to work by copying all the files, but losing the
directory structure. I tried that, but I still had missing datafiles at
runtime.

This function will return everything needed for py2exe to work correctly.
Instead of returning one tuple, it returns a list of tuples, so the use
changes a little bit, but at least it works.

def get_py2exe_datafiles():
   outdirname = 'matplotlibdata'
   mplfiles = []

   for root, dirs, files in os.walk(get_data_path()):
       py2exe_files = []

       # Append root to each file so py2exe can find them
       for file in files:
           py2exe_files.append(os.sep.join([root, file]))

       if len(py2exe_files) > 0:
           py2exe_root = root[len(get_data_path()+os.sep):]

           if len(py2exe_root) > 0:
               mplfiles.append((os.sep.join([outdirname, py2exe_root]),
py2exe_files))
           else:
               # Don't do a join for the root directory
               mplfiles.append((outdirname, py2exe_files))

   return mplfiles


Sorry for not submitting as a patch: I haven't quite figured out how to do
that yet.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to