On Thu, Jan 6, 2011 at 12:32 PM, John Hunter <jdh2...@gmail.com> wrote:
> On Thu, Jan 6, 2011 at 12:22 PM, John Hunter <jdh2...@gmail.com> wrote:
>
> > matplotlib_fname() always returns absolute path. I have not used
> > realpath, but if you think there is a use for it here, feel free to
> > post an amended patch.
>
> There is an exception to this -- if MATPLOTLIBRC or MPLCONFIGDIR are
> relative paths, then matplotlib_fname will return a relative path too.
>
Ah, all the more reason to apply abspath() or realpath(). To decide which
to use, let's consider the case of someone (like a developer) having
multiple builds of matplotlib in separate directories, and uses a symlink to
point to whichever he wants to use at the moment.
The question is, in this use-case, would we want the symbolic link pathname,
or the absolute pathname? I don't mess around with docs enough to know
which I would want.
I have attached a modified patch (which uses realpath(), but could easily be
changed to abspath()). I also included some comments to more fully document
what is going on and the rational for the logic being taken.
Ben Root
P.S. - Just to make sure, I noticed that rcParamsOrig is only in the
maintenance branch. It was intended to leave the development branch
"broken" for now until we get this working properly?
Index: lib/matplotlib/__init__.py
===================================================================
--- lib/matplotlib/__init__.py (revision 8898)
+++ lib/matplotlib/__init__.py (working copy)
@@ -762,6 +762,23 @@
# this is the instance used by the matplotlib classes
rcParams = rc_params()
+
+if rcParams['examples.directory']:
+ # paths that are intended to be relative to matplotlib_fname()
+ # are allowed for the examples.directory parameter.
+ # However, we will need to fully qualify the path because
+ # spinx requires absolute paths.
+ if not os.path.isabs(rcParams['examples.directory']):
+ _basedir, _fname = os.path.split(matplotlib_fname())
+
+ # Sometimes matplotlib_fname() can return relative paths,
+ # Also, using realpath() guarentees that spinx will use
+ # the same path that matplotlib sees (in case of weird symlinks).
+ _basedir = os.path.realpath(_basedir)
+
+ _fullpath = os.path.join(_basedir, rcParams['examples.directory'])
+ rcParams['examples.directory'] = _fullpath
+
rcParamsOrig = rcParams.copy()
rcParamsDefault = RcParams([ (key, default) for key, (default, converter) in \
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel