SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Paul K. <pki...@ni...> - 2007年10月02日 14:42:21
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
From: Michael D. <md...@st...> - 2007年10月02日 15:36:26
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:
 http://www.wxpython.org/docs/api/wx.tools.img2py-module.html
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
From: Paul K. <pki...@ni...> - 2007年10月04日 14:02:28
On Tue, Oct 02, 2007 at 10:42:13AM -0400, Paul Kienzle wrote:
> 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.
For the record, here is what I'm using to wrap matplotlib in py2exe.
Since I'm using the wx backend I've excluded Tkinter. 
Since numerix uses __import__, py2exe wasn't clever enough to find the 
numerix extensions, and had to be listed explicitly. Similarly 
for backends.
I'm not picking up the 14Mb of timezone info that I don't need. Maybe
want packages = ['pytz'] if your applications need it.
I haven't addressed mpl-data yet.
	- Paul
myapp.py
========
import pylab
pylab.plot(range(10),range(10))
pylab.show()
setup.py
========
from distutils.core import setup
import sys, os, py2exe
# data_files: List of datafiles that need to be explicitly included
# e.g., [('target/relative/path', ['file','list'])]
# excludes: List of modules to exclude (takes precedence over includes)
# dll_excludes: List of dlls to exclude
# includes: List of modules to include
# packages: List of packages to include
data_files = []
excludes = [ 'numarray', 'Numeric', 'Tkinter', ]
dll_excludes = [] # dlls to exclude
includes = [ 'matplotlib', 'wx', 'numpy', ]
packages = [] # May want 'wx' in packages if creating a generic environment
# Explicit package rules
if 'matplotlib' in includes:
 import matplotlib
 data_files += matplotlib.get_py2exe_datafiles()
 includes += ['matplotlib.numerix.'+pkg for pkg in
 ['ma','mlab','fft','linear_algebra','npyma','random_array']]
 includes += ['matplotlib.backends.backend_'+pkg for pkg in
 ['wx','wxagg','pdf','ps','svg','agg','agg2','emf']]
# Don't include anything explicitly excluded
includes = [x for x in includes if x not in excludes]
# Include the C/C++ runtime (there should be a way of putting these beside
# the python dll in the executable, but for now I put them in the executable
# directory. Note: the C++ runtime might be in the wx package instead of the
# python directory.
pythonpath = os.path.dirname(sys.executable)
c_runtime = pythonpath+"/MSVCR71.DLL"
cpp_runtime = pythonpath+"/MSVCP71.DLL"
data_files += [('.',[c_runtime,cpp_runtime])]
# End of configuration
py2exe_opts = dict(includes=includes, excludes=excludes,
 skip_archive=0, compressed=1,
 dll_excludes=dll_excludes, packages=packages,
 bundle_files=1, optimize=2)
setup(
 options = dict(py2exe=py2exe_opts),
 windows= ['myapp.py'], # Could be console=, depending on your app
 data_files = data_files,
 #zipfile = None, # Bundle library.zip with the executable
 )
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /