Skip to content
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

matplotlib not using persistent font cache #178

Closed
mreppen opened this issue Apr 16, 2018 · 6 comments
Closed

matplotlib not using persistent font cache #178

mreppen opened this issue Apr 16, 2018 · 6 comments
Labels
Milestone

Comments

@mreppen
Copy link

mreppen commented Apr 16, 2018

Expected Behavior

Use the default matplotlib font cache location, e.g., ~/.cache/matplotlib or artisan-specific directory like ~/.cache/artisan.

Actual Behavior

Uses temporary location, and thus has to rebuild cache at every run (takes a long time on my system).
In my case, it is written to a subdirectory of /tmp/, which of course is different every time artisan is run.

Specifications

  • Artisan Version: 1.3.0
  • Platform (Mac/Windows/Linux + OS version): Arch Linux running from .deb file (same on rpm)

Although I'm not using a supported distribution, the fact that the cache is stored in a temporary directory suggests the problem would occur also on other distributions.

@MAKOMO
Copy link
Member

MAKOMO commented Apr 16, 2018

Seems to be a platform specific issue. On Mac OS X (build with py2app) the users standard .matplotlib font cache is used or created/updated. Could be an issue on pyinstaller builds (Linux/Windows). Found this one: pyinstaller/pyinstaller#617

@rpaulo
Copy link
Member

rpaulo commented Apr 18, 2018

Looks like it's caused by how pyinstaller implements it:

pyinstaller/pyinstaller@213bfc3

@rpaulo
Copy link
Member

rpaulo commented Apr 18, 2018

Relevant explanation:

# When you run your onefile exe for the first time it's extracted to for example
# "_MEIxxxxx" temp directory and fontList.cache file is created with fonts paths
# pointing to this directory.
#
# Second time you run your exe new directory is created "_MEIyyyyy" but
# fontList.cache file still points to previous directory which was deleted.
# And then you will get error like:
#
#     RuntimeError: Could not open facefile
#
# We need to force matplotlib to recreate config directory every time you run
# your app.

@rpaulo
Copy link
Member

rpaulo commented Apr 18, 2018

@mreppen I suspect that fixing this will create other problems...

@mreppen
Copy link
Author

mreppen commented Apr 18, 2018

The description of the behavior is not entirely clear to me, likely because I don't really know PyInstaller.

It seems to me like the hook with that comment is responsible for setting up the new temporary mpl directory. Why couldn't it just copy/link the fontList.cache from the default directory?

@rpaulo
Copy link
Member

rpaulo commented Apr 19, 2018

rpaulo added a commit that referenced this issue Apr 22, 2018
@MAKOMO MAKOMO added this to the v1.3.1 milestone May 7, 2018
@MAKOMO MAKOMO added the bug label May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants