Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e799ffb

Browse filesBrowse files
committed
Support pathological tmpdirs in TexManager.
tex does not support paths that contain tildes, and tmpdir may be such a path. Fortunately, we can arrange to refer to paths relatively instead. No test, as that would involve setting up another MPLCONFIGDIR just for that purpose, which is rather costly as we'd need to regen the font cache for it. But one can try e.g. ``` MPLCONFIGDIR=/tmp/has~tilde python -c 'from pylab import *; figtext(.5, .5, "a", usetex=True); show()' ```
1 parent fea21af commit e799ffb
Copy full SHA for e799ffb

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+6-3Lines changed: 6 additions & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.