Closed
Description
On Windows with mpl 1.2.0rc2, the following script successfully creates the figure but prints an error: could not delete tmp directory c:\users\...\temp\tmph2fo4m
import matplotlib
matplotlib.use('pgf')
from matplotlib import pyplot
pyplot.plot()
pyplot.savefig("test.pdf")
The backend_pgf fails to delete temporary directories because a latex process is started from the temporary directory. On Windows, directories and files can not be deleted while they are in use. The following code found in backend_pgf is also not thread safe:
tmpdir = tempfile.mkdtemp()
cwd = os.getcwd()
os.chdir(tmpdir)
...
self.print_pgf("figure.pgf") # starts LatexManager in tmpdir
...
os.chdir(cwd)
shutil.rmtree(tmpdir) # fails because LatexManager is still open in tmpdir