-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate the MATPLOTLIBDATA environment variable. #11241
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
Conversation
in Debian we also use to build the documentation:
to run the test suite:
how would we achieve the same result when |
Is installing Matplotlib in a venv and building the docs from there acceptable for Debian? Or apply your mpl-data-moving patch after building the docs. Or patch doc/conf.py to make it apply a patch to |
sadly it's not possible to build mpl in a venv and use it to build the documentation (it's just how the debian packaging system works). i understand your suggestions, but i have to make something acceptable by the debian ecosystem, in this case:
if you really want to get rid of MATPLOTLIBDATA, i'll just keep it around as a debian patch, no bid deal |
Can you point to me where these rules are listed? Edit: Or perhaps you can patch get_data_path() to add Debian's path as a last fallback. This way, when setting PYTHONPATH to the just-built Matplotlib, it'll use the "normal" path, but when the end-user is importing Matplotlib, the last-fallback path will be used. Or as suggested above you can patch
|
Tests are run against the installed matplotlib in Fedora during build. The reason that |
Would patching to
work? |
Actually, though I haven't looked into the history of it, I think the main reason for separating things is to avoid installing twice for Python 2 and 3, but with Matplotlib 3 only supporting Python 3 now... |
2052e3b
to
d62a243
Compare
The MATPLOTLIBDATA environment variable is only relevant to non-standard installs (e.g., debian) that move the mpl-data directory to a separate location (in debian's case, /usr/share/matplotlib/mpl-data); but for whoever is already patching Matplotlib to achieve this, they may as well also patch `get_data_path` to always return the new correct path (which debian already does in their `20_matplotlibrc_path_search_fix.patch`), reproduced here: diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 9339707..563b0a8 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -738,10 +738,12 @@ def _get_data_path(): return path _file = _decode_filesystem_path(__file__) - path = os.sep.join([os.path.dirname(_file), 'mpl-data']) + path = '/usr/share/matplotlib/mpl-data' if os.path.isdir(path): return path + raise RuntimeError('Could not find the matplotlib data files') + # setuptools' namespace_packages may highjack this init file # so need to try something known to be in matplotlib, not basemap import matplotlib.afm @@ -836,7 +838,7 @@ def matplotlib_fname(): yield matplotlibrc yield os.path.join(matplotlibrc, 'matplotlibrc') yield os.path.join(_get_configdir(), 'matplotlibrc') - yield os.path.join(get_data_path(), 'matplotlibrc') + yield '/etc/matplotlibrc' for fname in gen_candidates(): if os.path.exists(fname):
d62a243
to
404ff5d
Compare
Re-pinging @QuLogic @sandrotosi after #11241 (comment). Thanks in advance for your input. |
I think that is reasonable and would work fine; the self-contained destdir is supposed to mirror the final install exactly after all. |
I am -0.5 on this. I don't see much of an upside and see a downside of making the debian packaging a bit more annoying. |
The upside is ultimately switching to https://docs.python.org/3/library/importlib.html#module-importlib.resources (Py3.7+) instead of having to bother with _get_data_path at all, and completely remove the rcparam... |
FWIW the final patch would make
and not even store it in rcParams (because it doesn't make sense to let the user modify it later anyways -- many things, e.g. the included font paths, are set in stone at import time). |
let me just re-state what i said before: i totally understand if you want to get rid of MATPLOTLIBDATA env var to make mpl code easier to maintain. OTOH we kinda like the ability to specify where the i'm just fine to come up with a debian-specific patch to support our needs if you ultimately decide to drop MATPLOTLIBDATA |
@tacaswell Are you willing to revisit this based on the comments so far? Happy to help with the Debian-specific patch if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm, seems fine to me. OTOH I think @tacaswell should merge....
@sandrotosi this is coming for 3.1 (next month-ish). |
…241-on-v3.1.x Backport PR #11241 on branch v3.1.x (Deprecate the MATPLOTLIBDATA environment variable.)
One minor inconvenience here is that if you're running with a patched path (using |
But the baseline images aren't found relative to the data dir? I'm not sure what the issue is, but would be happy to hear more. |
The MATPLOTLIBDATA environment variable is only relevant to non-standard
installs (e.g., debian) that move the mpl-data directory to a separate
location (in debian's case, /usr/share/matplotlib/mpl-data); but for
whoever is already patching Matplotlib to achieve this, they may as well
also patch
get_data_path
to always return the new correct path (whichdebian already does in their
20_matplotlibrc_path_search_fix.patch
),reproduced here:
attn @sandrotosi I guess :)
PR Summary
PR Checklist