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

Fix error generation for missing pgf.texsystem. #26689

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

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions 29 lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,24 +241,14 @@ def __init__(self):
self._finalize_tmpdir = weakref.finalize(self, self._tmpdir.cleanup)

# test the LaTeX setup to ensure a clean startup of the subprocess
try:
self._setup_latex_process(expect_reply=False)
except FileNotFoundError as err:
raise RuntimeError(
f"{self.latex.args[0]!r} not found. Install it or change "
f"rcParams['pgf.texsystem'] to an available TeX "
f"implementation.") from err
except OSError as err:
raise RuntimeError(
f"Error starting process {self.latex.args[0]!r}") from err
self._setup_latex_process(expect_reply=False)
stdout, stderr = self.latex.communicate("\n\\makeatletter\\@@end\n")
if self.latex.returncode != 0:
raise LatexError(
f"LaTeX errored (probably missing font or error in preamble) "
f"while processing the following input:\n"
f"{self._build_latex_header()}",
stdout)

self.latex = None # Will be set up on first use.
# Per-instance cache.
self._get_box_metrics = functools.lru_cache(self._get_box_metrics)
Expand All @@ -268,10 +258,19 @@ def _setup_latex_process(self, *, expect_reply=True):
# Windows, we must ensure that the subprocess has quit before being
# able to delete the tmpdir in which it runs; in order to do so, we
# must first `kill()` it, and then `communicate()` with it.
self.latex = subprocess.Popen(
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
encoding="utf-8", cwd=self.tmpdir)
try:
self.latex = subprocess.Popen(
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
encoding="utf-8", cwd=self.tmpdir)
except FileNotFoundError as err:
raise RuntimeError(
f"{mpl.rcParams['pgf.texsystem']!r} not found; install it or change "
f"rcParams['pgf.texsystem'] to an available TeX implementation"
) from err
except OSError as err:
raise RuntimeError(
f"Error starting {mpl.rcParams['pgf.texsystem']!r}") from err

def finalize_latex(latex):
latex.kill()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.