Quantcast
Channel: Uncategorized - Matplotlib
Viewing all articles
Browse latest Browse all 61

How should PyInstaller handle MPLCONFIGDIR?

$
0
0

Hello, I’m looking for some advice as to whether or not I should accept a PR to stop PyInstaller from redirecting MPLCONFIGDIR to a temporary directory.

(For those who don’t know, PyInstaller is one of the tools that can turn Python code into self-contained applications that someone can run without installing Python/pip/$packages/etc. Such applications are expected to be fairly well insulated so that a user who has never heard of Python doesn’t end up with two applications cross-talking preferences or stomping each other caches due to a shared dependency with a singleton cache/config directory.)

The history: PyInstaller started setting MPLCONFIGDIR to a temporary directory many years ago as a workaround to some absolute paths to matplotlib in the font cache breaking relocatability. This effectively defeats the cache so the obvious side effect is that startup time is bad. The relocatability issue has since been fixed in matplotlib but we’ve been reluctant to drop our MPLCONFIGDIR setter due to other concerns of different applications or possibly matplotlib installed normally each messing with each other – say an application that fails to start because the config tells it to use a backend that the application does not contain.

I notice the font cache in ~/.cache/matplotlib is versioned so that should make it a bit safer although I suspect it could still cause trouble if an application carrying matplotlib with its fonts removed[1] generates the cache then other instances of matplotlib can no longer find their own fonts.

My ~/.config/matplotlib/ directory is always empty so I can’t figure out if/what gets put in there or what versioning/protections it has? I thought it contained the default backend and some implicit preferences from the graph rendering window but my brain may have made that up.

So the question is, can we stop trying to clumsily isolate matplotlib ourselves and trust that the existing protections for multiple versions of matplotlib being installed are sufficient?


  1. Yes, that is common usage. People get very trigger happy when it comes to removing apparently “dead weight” from their application once it’s outside of the relative obscurity of site-packages and they can now see how big it is. ↩︎

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 61

Latest Images

Trending Articles



Latest Images