Skip to content

Commit 5dc1f19

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #21414: Support pathological tmpdirs in TexManager.
1 parent 7e36e90 commit 5dc1f19

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/texmanager.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,19 @@ def make_dvi(self, tex, fontsize):
258258
basefile = self.get_basefile(tex, fontsize)
259259
dvifile = '%s.dvi' % basefile
260260
if not os.path.exists(dvifile):
261-
texfile = self.make_tex(tex, fontsize)
261+
texfile = Path(self.make_tex(tex, fontsize))
262262
# Generate the dvi in a temporary directory to avoid race
263263
# conditions e.g. if multiple processes try to process the same tex
264264
# string at the same time. Having tmpdir be a subdirectory of the
265265
# final output dir ensures that they are on the same filesystem,
266-
# and thus replace() works atomically.
266+
# and thus replace() works atomically. It also allows referring to
267+
# the texfile with a relative path (for pathological MPLCONFIGDIRs,
268+
# the absolute path may contain characters (e.g. ~) that TeX does
269+
# not support.)
267270
with TemporaryDirectory(dir=Path(dvifile).parent) as tmpdir:
268271
self._run_checked_subprocess(
269272
["latex", "-interaction=nonstopmode", "--halt-on-error",
270-
texfile], tex, cwd=tmpdir)
273+
f"../{texfile.name}"], tex, cwd=tmpdir)
271274
(Path(tmpdir) / Path(dvifile).name).replace(dvifile)
272275
return dvifile
273276

0 commit comments

Comments
 (0)