From: Benjamin R. <ben...@ou...> - 2010-10-28 19:27:14
|
On Thu, Oct 28, 2010 at 1:50 PM, John Hunter <jd...@gm...> wrote: > On Thu, Oct 28, 2010 at 1:11 PM, Christopher Barker > <Chr...@no...> wrote: > > On 10/25/10 1:41 PM, Daniel Hyams wrote: > >> It doesn't really insist on it right? There are MATPLOTLIBDIR and > >> MPLCONFIGDIR environment variables. > > > >> You can set these env variables within your code, before import of > >> matplotlib via os.environment. > > > > I'm glad I've learned about this, and will start doing it with my > > bundled up apps -- but that does seem pretty un-pythonic -- shouldn't it > > be possible to set this sort of thing without resorting to that little > > round trip through environment variables? > > > > Not a big deal, but it feels kludgy. > > The MPLCONFIGDIR tells mpl where to find the config file. It's hard > to read the config, no matter how pythonic it is, if you don't know > where it is. Once the config file (matplotlibrc) is located you can > set the datapath with the 'datapath' parameter so you don't need > MATPLOTLIBDATA (which is only used if datapath is not set). From the > rc file: > > > # Where your matplotlib data lives if you installed to a non-default > # location. This is where the matplotlib fonts, bitmaps, etc reside > #datapath : /home/jdhunter/mpldata > > > We could use command line args, but mpl is a library and shouldn't > really be using them... Arguably we are already doing too much in the > way of command line args. > > JDH > > Isn't this a problem with any program/library? Could we go a route where (for *nix) we check the current working directory for the file, then check the user account's .local directory, then check the /etc directory for the any remaining settings? Maybe for Windows use (dare I say it!) the registry? (Please excuse the registry idea if this completely flies in the face of modern Windows development practices, I haven't programmed in Windows since my days of taking AP Computer Science ten years ago). Ben Root |