From 5dc1f1911cd55bd3cf0524b9bfdcf99650d301be Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 21 Oct 2021 12:18:44 -0400 Subject: [PATCH] Backport PR #21414: Support pathological tmpdirs in TexManager. --- lib/matplotlib/texmanager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index b61e8b7acff3..62aca98a32b6 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -258,16 +258,19 @@ def make_dvi(self, tex, fontsize): basefile = self.get_basefile(tex, fontsize) dvifile = '%s.dvi' % basefile if not os.path.exists(dvifile): - texfile = self.make_tex(tex, fontsize) + texfile = Path(self.make_tex(tex, fontsize)) # Generate the dvi in a temporary directory to avoid race # conditions e.g. if multiple processes try to process the same tex # string at the same time. Having tmpdir be a subdirectory of the # final output dir ensures that they are on the same filesystem, - # and thus replace() works atomically. + # and thus replace() works atomically. It also allows referring to + # the texfile with a relative path (for pathological MPLCONFIGDIRs, + # the absolute path may contain characters (e.g. ~) that TeX does + # not support.) with TemporaryDirectory(dir=Path(dvifile).parent) as tmpdir: self._run_checked_subprocess( ["latex", "-interaction=nonstopmode", "--halt-on-error", - texfile], tex, cwd=tmpdir) + f"../{texfile.name}"], tex, cwd=tmpdir) (Path(tmpdir) / Path(dvifile).name).replace(dvifile) return dvifile pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy