Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Simplify tmpdir handling in backend_pgf.#18654

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:masterfromanntzer:pgftmpdir
Oct 7, 2020

Conversation

anntzer
Copy link
Contributor

backend_pgf uses a complicated way to handle temporary directories, in
particular because (on top of the normal calls to tex) it runs a
separate, long-standing tex instance to compute text bounding boxes.
I'm not sure this is actually needed, but at least, for the places
where we just run tex locally, we can certainly just use normal
TemporaryDirectories with automatic cleanup.

Do so in _print_pdf_to_fh (also with some pathlibification),
_print_png_to_fh, and PdfPages._run_latex (where all the temporary files
can be set up in_run_latex, rather than in__init__, which saves
the need for a bunch of attributes).

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings andpydocstyle<4 and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

shutil.rmtree(tmpdir)
except:
TmpDirCleaner.add(tmpdir)
with TemporaryDirectory() as tmpdir:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We seriously don't have even a smoketest for this method?

Copy link
Contributor

@dopplershiftdopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good. Would love to have a test exercise the entirely unexecuted method.

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agree that an example would be good.

backend_pgf uses a complicated way to handle temporary directories, inparticular because (on top of the normal calls to tex) it runs aseparate, long-standing tex instance to compute text bounding boxes.I'm not sure this is actually needed, but at least, for the placeswhere we just run tex locally, we can certainly just use normalTemporaryDirectories with automatic cleanup.Do so in _print_pdf_to_fh (also with some pathlibification),_print_png_to_fh, and PdfPages._run_latex (where all the temporary filescan be set up in `_run_latex`, rather than in `__init__`, which savesthe need for a bunch of attributes).
@anntzer
Copy link
ContributorAuthor

Added a smoketest. I really don't want to add a new baseline image here because even the current pgf tests don't pass locally; my suspicion is that we have the same problem as with freetype versions, but worse because now it's the freetype versions used by the tex machinery, which we don't control...

@QuLogic
Copy link
Member

The problem thatTmpDirCleaner is trying to solve is that on Windows you can't delete a file that's open. I don't thinkTemporaryDirectory handles this, and may cause unexpected crashes on saving.

@anntzer
Copy link
ContributorAuthor

My understanding is that that's relevant for the long-running LatexManager (and even then my guess is that we could arrange for LatexManager to properly clean after itself). Here we're only looking at fully self-contained tex invocations, which should all be done by the end of the block.

@QuLogic
Copy link
Member

It seems like all these code paths end up going throughsubprocess.run, which is supposed to wait for the process, so maybe these are all okay? Hard to say without a slow Windows to check.

@anntzer
Copy link
ContributorAuthor

That's my point. Compare withLatexManager, which keeps the subprocess around for the whole duration of the python process.

@QuLogic
Copy link
Member

Well, let's see if anyone complains.

@QuLogicQuLogic merged commite5404d8 intomatplotlib:masterOct 7, 2020
@anntzeranntzer deleted the pgftmpdir branchOctober 7, 2020 09:08
@anntzer
Copy link
ContributorAuthor

Ah, it looks like some of this was also fixed on Python 3.4 per#1324 (comment). In any case I've confirmed locally that things work on Windows.

@QuLogicQuLogic added this to thev3.4.0 milestoneJun 29, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dopplershiftdopplershiftdopplershift approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

4 participants
@anntzer@QuLogic@dopplershift@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp