@@ -241,24 +241,14 @@ def __init__(self):
241
241
self ._finalize_tmpdir = weakref .finalize (self , self ._tmpdir .cleanup )
242
242
243
243
# test the LaTeX setup to ensure a clean startup of the subprocess
244
- try :
245
- self ._setup_latex_process (expect_reply = False )
246
- except FileNotFoundError as err :
247
- raise RuntimeError (
248
- f"{ self .latex .args [0 ]!r} not found. Install it or change "
249
- f"rcParams['pgf.texsystem'] to an available TeX "
250
- f"implementation." ) from err
251
- except OSError as err :
252
- raise RuntimeError (
253
- f"Error starting process { self .latex .args [0 ]!r} " ) from err
244
+ self ._setup_latex_process (expect_reply = False )
254
245
stdout , stderr = self .latex .communicate ("\n \\ makeatletter\\ @@end\n " )
255
246
if self .latex .returncode != 0 :
256
247
raise LatexError (
257
248
f"LaTeX errored (probably missing font or error in preamble) "
258
249
f"while processing the following input:\n "
259
250
f"{ self ._build_latex_header ()} " ,
260
251
stdout )
261
-
262
252
self .latex = None # Will be set up on first use.
263
253
# Per-instance cache.
264
254
self ._get_box_metrics = functools .lru_cache (self ._get_box_metrics )
@@ -268,10 +258,19 @@ def _setup_latex_process(self, *, expect_reply=True):
268
258
# Windows, we must ensure that the subprocess has quit before being
269
259
# able to delete the tmpdir in which it runs; in order to do so, we
270
260
# must first `kill()` it, and then `communicate()` with it.
271
- self .latex = subprocess .Popen (
272
- [mpl .rcParams ["pgf.texsystem" ], "-halt-on-error" ],
273
- stdin = subprocess .PIPE , stdout = subprocess .PIPE ,
274
- encoding = "utf-8" , cwd = self .tmpdir )
261
+ try :
262
+ self .latex = subprocess .Popen (
263
+ [mpl .rcParams ["pgf.texsystem" ], "-halt-on-error" ],
264
+ stdin = subprocess .PIPE , stdout = subprocess .PIPE ,
265
+ encoding = "utf-8" , cwd = self .tmpdir )
266
+ except FileNotFoundError as err :
267
+ raise RuntimeError (
268
+ f"{ mpl .rcParams ['pgf.texsystem' ]!r} not found; install it or change "
269
+ f"rcParams['pgf.texsystem'] to an available TeX implementation"
270
+ ) from err
271
+ except OSError as err :
272
+ raise RuntimeError (
273
+ f"Error starting { mpl .rcParams ['pgf.texsystem' ]!r} " ) from err
275
274
276
275
def finalize_latex (latex ):
277
276
latex .kill ()
0 commit comments