From 01f4b57ce4e774b9397b1e27b803e50960aeacef Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 2 Apr 2021 16:53:57 -0400 Subject: [PATCH 1/2] MNT: make the source installed backend default and installed match There is logic in setup.py to either set the value to a build-time config (so packagers can be opinionated about the default) or empty to get the fallback default. When working on a source-install this logic is not run. --- lib/matplotlib/mpl-data/matplotlibrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc index 27a2a144bedd..6cafe50f6cde 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -78,7 +78,7 @@ ## PS PDF SVG Template ## You can also deploy your own backend outside of Matplotlib by referring to ## the module name (which must be in the PYTHONPATH) as 'module://my_backend'. -#backend: Agg +#backend: ## The port to use for the web server in the WebAgg backend. #webagg.port: 8988 From 72641124a00a0f66f436deeb9ee278303e6967ab Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 2 Apr 2021 16:55:19 -0400 Subject: [PATCH 2/2] FIX: ignore empty backend value in matplotlibrc See comment in code. Accounts for the fact that we can to directly specify the "fallback" backend value. This interprets the lack of a backend entry and an empty backend entry the same. closes #19848 --- lib/matplotlib/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 856686e4f1de..75601ac6dd75 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -769,6 +769,17 @@ def _rc_params_in_file(fname, transform=lambda x: x, fail_on_error=False): for key, (val, line, line_no) in rc_temp.items(): if key in rcsetup._validators: + # the backend parameter is special because the default value can + # not be expressed in the matplotlibrc file (the default is an + # internal sentinel to indicated that we should do backend fallback + # which picks the first importable interactive backend we find). + # + # This allows the backend parameter to be unset (as opposed to + # not present) in the matplotlibrc file. This is important because + # the defaults are pulled from a (fully commented out) template + # including with the installation. + if key == 'backend' and val == '': + continue if fail_on_error: config[key] = val # try to convert to proper type or raise else: