Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend_pgf does not delete temp directories on Windows, changes the current directory #1281

Closed
cgohlke opened this issue Sep 19, 2012 · 3 comments
Assignees
Milestone

Comments

@cgohlke
Copy link
Contributor

cgohlke commented Sep 19, 2012

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
@ghost ghost assigned pwuertz Sep 20, 2012
@pwuertz
Copy link
Contributor

pwuertz commented Sep 20, 2012

Ok, lets try giving LatexManager its own tmpdir...

@pwuertz
Copy link
Contributor

pwuertz commented Sep 20, 2012

By not thread safe you probably mean the use of os.chdir?

@pwuertz
Copy link
Contributor

pwuertz commented Sep 22, 2012

It seems that there is no direct way of fixing this on windows. Continuing the discussion in the referenced pull request.

@pwuertz pwuertz closed this as completed Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants