In article 
<[EMAIL PROTECTED]>,
 "Charlie Moad" <[EMAIL PROTECTED]> wrote:

> On 6/2/06, Russell E. Owen <[EMAIL PROTECTED]> 
> wrote:
> > I'm using matplotlib in an application I distribute. For Windows and Mac
> > users I distribute a frozen application which includes python,
> > matplotlib, etc. and I'm wondering how best to include the matplotlib
> > data files.
> >
> > matplotlib searches for its data files in __init__._get_data_path. It
> > seems to search shared locations first, then locations that would be
> > relevant to a frozen application. Is that safe? I worry that if a user
> > of my app has their own version of matplotlib (possibly a very different
> > version than I've included) then the data files might be different.
> >
> > If this really is an issue, then what to do?
> 
> The only way you could have conflicting data sources is if
> MATPLOTLIBDATA is defined in your environment. 
> of setting that I am inclined to think they might know what to do in
> case of an error.  If that env var is not set, then mpl looks inside
> the its module.  Different installs will not see the others.  We
> finally have a special case for frozen installations.  It has
> primarily been made for py2exe, in which you should have a folder
> called 'matplotlibdata' in your app's bundle.

OK, thanks. I had not realized that so few dirs were searched on Windows 
as compared to unix/MacOS X, but you're right. So although the test for 
frozen windows versions comes last, there's not much to collide with 
before that.

> > For Mac I can put the data files deep in the app in
> > Contents/Frameworks/Python.Framework/2.4/share/matplotlib, which is the
> > second location looked at (after environment variable MATPLOTLIBDATA).
> 
> The second location should be:
> ....Frameworks/Python.Framework/2.4/lib/python2.4/matplotlib/mpl-data
> 
> Are you using an old version of matplotlib?

I guess it's a bit old. 0.82. I need something built for MacOS X 10.3.9 
so my bundled app runs on that.

Thanks for the heads up on the changed path. Maybe I'll remember to fix 
my bundling code when I upgrade matplotlib.

> > For Windows, there doesn't seem any way out. The Windows frozen test is
> > dead last.
> 
> You can remove the MATPLOTLIBDATA env var from os.environ in your code.

Great idea. I'll do that. Thanks!

> In my experience with distributing apps with matplotlib, I have known
> in advanced the packages I want to use.  For example, if I know I am
> going to bundle Tkinter and numpy, then I make sure I have the
> following before using any matplotlib commands.
> 
> import matplotlib
> matplotlib.use('TkAgg')
> matplotlib.rcParams['numerix'] = 'numpy'

Thanks for the tip. I knew about the first one, but not the second!

-- Russell



_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to