@@ -258,16 +258,19 @@ def make_dvi(self, tex, fontsize):
258
258
basefile = self .get_basefile (tex , fontsize )
259
259
dvifile = '%s.dvi' % basefile
260
260
if not os .path .exists (dvifile ):
261
- texfile = self .make_tex (tex , fontsize )
261
+ texfile = Path ( self .make_tex (tex , fontsize ) )
262
262
# Generate the dvi in a temporary directory to avoid race
263
263
# conditions e.g. if multiple processes try to process the same tex
264
264
# string at the same time. Having tmpdir be a subdirectory of the
265
265
# 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.)
267
270
with TemporaryDirectory (dir = Path (dvifile ).parent ) as tmpdir :
268
271
self ._run_checked_subprocess (
269
272
["latex" , "-interaction=nonstopmode" , "--halt-on-error" ,
270
- texfile ], tex , cwd = tmpdir )
273
+ f"../ { texfile . name } " ], tex , cwd = tmpdir )
271
274
(Path (tmpdir ) / Path (dvifile ).name ).replace (dvifile )
272
275
return dvifile
273
276
0 commit comments