|
From: John P. <joh...@st...> - 2006-04-18 14:17:09
|
John Hunter wrote: > John> I don't have one and I don't think it's good design for my > John> software installer to go creating one for people as part of > John> a larger software installation. I think that sniffing would > John> be a better (complementary, not replacement) solution, so > John> that whichever the user decides to install, it just works. > > You have a few options. You can set the rc parameters inside your > script, you do not need to change a system wide rc file > > from matplotlib import rcParams > rcParams['numerix'] = 'numpy' > #...now import matplotlib.numerix, pylab, etc... > That's what I'm currently using, actually (see start of this thread). > You can also provide per directory configuration files. Ie, you can > create a matplotlibrc file (http://matplotlib.sf.net/matplotlibrc) in > the same dir as your main-level script, and it will respect that one > so you need not worry about overriding a system rc file when you > install your software. > I already have a config file for our application, if I did anything like this it would be to add an extra option to our existing config file, not create an additional one. Although this one was nice to know. > John> For now I will select numpy. Is that the one that Matplotlib > John> looks for first? > > There are two issues here: build time configuration and run time > configuration. We used to do neither, now at built time we try and > find one of numpy/numarray/Numeric (in that order) and then generate > an rc file with the found one as the default. > > We could also do run time dynamic imports. I'm of two minds here: the > more we try and do automatically, the harder it is to detect and fix > bugs and problems when they arise. The setup is already pretty > complex, if we are automatically choosing numerix and backend > settings, I could see some difficulties in debugging problems. But I > can see the advantages to it as well... > I'm thinking that *if* a preference has been specified, that should be used (and possibly throw and error if it fails). But if no preference is specified, then a sniffing approach should work, something like the following, which has worked for me without any issues so far, on a number of different platforms. This approach would facilitate debugging, knowing that you can force a particular numeric-array import. try: import psyco psyco.full() print "Running with PSYCO optimisation..." except ImportError: pass -- John Pye Department of Mechanical and Manufacturing Engineering University of New South Wales, Sydney, Australia http://pye.dyndns.org/ |