Skip to content

Commit 0805a5b

Browse files
committed
Move checkdep_ps_distiller to the rc validators.
1 parent 1038a45 commit 0805a5b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ def checkdep_inkscape():
441441
checkdep_inkscape.version = None
442442

443443

444+
@cbook.deprecated("2.2")
444445
def checkdep_ps_distiller(s):
445446
if not s:
446447
return False
@@ -450,7 +451,7 @@ def checkdep_ps_distiller(s):
450451
return False
451452
if s == "xpdf" and not get_executable_info("pdftops"):
452453
warnings.warn(
453-
"setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
454+
"Setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
454455
return False
455456
return s
456457

@@ -1067,9 +1068,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
10671068
six.iteritems(defaultParams)
10681069
if key not in _all_deprecated])
10691070

1070-
rcParams['ps.usedistiller'] = checkdep_ps_distiller(
1071-
rcParams['ps.usedistiller'])
1072-
10731071
rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
10741072

10751073
if rcParams['axes.formatter.use_locale']:

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import warnings
2626
import re
2727

28+
import matplotlib as mpl
2829
from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper
2930
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
3031
from matplotlib.colors import is_color_like
@@ -505,7 +506,12 @@ def validate_ps_distiller(s):
505506
elif s in ('false', False):
506507
return False
507508
elif s in ('ghostscript', 'xpdf'):
508-
return s
509+
if not mpl.get_executable_info("gs"):
510+
warnings.warn("Setting ps.usedistiller requires ghostscript.")
511+
return False
512+
if s == "xpdf" and not mpl.get_executable_info("pdftops"):
513+
warnings.warn("Setting ps.usedistiller to 'xpdf' requires xpdf.")
514+
return False
509515
else:
510516
raise ValueError('matplotlibrc ps.usedistiller must either be none, '
511517
'ghostscript or xpdf')

0 commit comments

Comments
 (0)