py2exe wisdom

As I was building a py2exe distribution of matplotlib, I noticed the
function get_py2exe_datafiles() in __init__.py that is not noted on
the FAQ. Before I update the FAQ, can you all tell me your best
practices recommendations for wrapping matplotlib?

In particular, is there a way I can store the matplotlib data directly
in the exe so that install is simply a matter of copying an exe file
rather than a whole directory?

Technically this should be feasible --- freetype can load fonts
from memory or directly from the zip file given the proper driver,
and the various images should be similarly readable.

  - Paul

Paul Kienzle wrote:

Technically this should be feasible --- freetype can load fonts
from memory or directly from the zip file given the proper driver,
and the various images should be similarly readable.

ttconv will have to be likewise updated (probably to accept a Python file-like object). It is currently hardcoded to only accept file paths and do its own reading using the C stdlib.

The Cairo backend will also be unable to use fonts this way (but that's only a minor change from how it is now -- Cairo can only read fonts from normal OS-specific font installation directories anyway.)

Personally, I'd prefer to see the fonts installed in a OS standard place -- then matplotlib could use fontconfig effectively on X11 systems and Cairo would function like all the other backends. But that probably means having a proper installer on Windows/Mac and being a little more clever with packaging on Linux.

As for images, you could take the approach suggested by wxPython's img2py:

   wxPython API Documentation — wxPython Phoenix 4.2.1 documentation

There is nothing wx-specific about the concepts there... But I'm not sure it's necessary if all of the backends can load images from strings anyway.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA