bug in plot_basedir and changed default directory in plot_directive?

It seems that this commit [1] changed the default directory for the
sphinx plots directory (now needs to be alongside the directive and
not in the directory above it?) and now our project's docs will not
build across different versions of matplotlib without some magic. So I
tried setting

from os.path import dirname, abspath
plot_basedir = dirname(dirname(abspath(__file__)))

in our sphinx conf.py. We have source/conf.py and plots/ is in the
parent directory of source for the directive plot::
plots/some_file.py. However, now I get this error [2] and this
traceback [3]. It seems the build/plot_directive folder is created
before a subsequent call to os.makedir. If I move plots to its
expected default location and then set the plot_basedir manually it's
fine. Is this a bug or user error? Is there some reason our plots
directory can't be in the parent directory of source?

[1] https://github.com/matplotlib/matplotlib/commit/a205f5460f13d47aa5b5fad662005c382dd096ee
[2] http://pastebin.com/KQp11CiS
[3] http://pastebin.com/4LY1Pt1Q

Skipper

Ok, there were two things going on here. First, when build_dir is
created it is joined with a relative path that will include '..' if
necessary. matplotlib.cbook.mkdirs does not handle this correctly, but
os.makedirs does. Is there a good reason to keep cbook.mkdirs? This
problem could also be solved with a call to os.path.normpath, which is
needed for the next issue anyway.

Second, since we call our source folder plots, there is a conflict
when trying to copy it over at the end to the destination directory.

This commit adds a call to os.path.normpath, replaces cbook.mkdirs
with os.makedirs, and only copies the plots to the destination
directory if there's a need.

https://github.com/matplotlib/matplotlib/pull/132

Skipper

ยทยทยท

On Tue, May 31, 2011 at 9:18 PM, Skipper Seabold <jsseabold@...149...> wrote:

It seems that this commit [1] changed the default directory for the
sphinx plots directory (now needs to be alongside the directive and
not in the directory above it?) and now our project's docs will not
build across different versions of matplotlib without some magic. So I
tried setting

from os.path import dirname, abspath
plot_basedir = dirname(dirname(abspath(__file__)))

in our sphinx conf.py. We have source/conf.py and plots/ is in the
parent directory of source for the directive plot::
plots/some_file.py. However, now I get this error [2] and this
traceback [3]. It seems the build/plot_directive folder is created
before a subsequent call to os.makedir. If I move plots to its
expected default location and then set the plot_basedir manually it's
fine. Is this a bug or user error? Is there some reason our plots
directory can't be in the parent directory of source?

[1] https://github.com/matplotlib/matplotlib/commit/a205f5460f13d47aa5b5fad662005c382dd096ee
[2] http://pastebin.com/KQp11CiS
[3] http://pastebin.com/4LY1Pt1Q

Skipper