Skip to content

Commit c1d8bbb

Browse files
committed
Move checkdep_ps_distiller to the rc validators.
1 parent 6110c7c commit c1d8bbb

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

lib/matplotlib/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ def checkdep_inkscape():
541541
checkdep_inkscape.version = None
542542

543543

544+
@cbook.deprecated("2.2")
544545
def checkdep_ps_distiller(s):
545546
if not s:
546547
return False
@@ -550,7 +551,7 @@ def checkdep_ps_distiller(s):
550551
return False
551552
if s == "xpdf" and not get_executable_info("pdftops"):
552553
warnings.warn(
553-
"setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
554+
"Setting matplotlibrc ps.usedistiller to 'xpdf' requires xpdf.")
554555
return False
555556
return s
556557

@@ -1166,9 +1167,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
11661167
six.iteritems(defaultParams)
11671168
if key not in _all_deprecated])
11681169

1169-
rcParams['ps.usedistiller'] = checkdep_ps_distiller(
1170-
rcParams['ps.usedistiller'])
1171-
11721170
rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
11731171

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

lib/matplotlib/backends/backend_pgf.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
2222
RendererBase)
2323
from matplotlib.backends.backend_mixed import MixedModeRenderer
24-
from matplotlib.cbook import _backports, is_writable_file_like
24+
from matplotlib.cbook import is_writable_file_like
2525
from matplotlib.compat import subprocess
2626
from matplotlib.compat.subprocess import check_output
2727
from matplotlib.path import Path
@@ -167,20 +167,20 @@ def _font_properties_str(prop):
167167

168168
def make_pdf_to_png_converter():
169169
"""Returns a function that converts a pdf file to a png file."""
170-
if _backports.which("pdftocairo"):
170+
if shutil.which("pdftocairo"):
171171
def cairo_convert(pdffile, pngfile, dpi):
172-
cmd = [str("pdftocairo"), "-singlefile", "-png", "-r", "%d" % dpi,
172+
cmd = ["pdftocairo", "-singlefile", "-png", "-r", "%d" % dpi,
173173
pdffile, os.path.splitext(pngfile)[0]]
174174
check_output(cmd, stderr=subprocess.STDOUT)
175175
return cairo_convert
176176
if mpl.get_executable_info("gs"):
177177
def gs_convert(pdffile, pngfile, dpi):
178-
cmd = [str(gs),
179-
'-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dNOPROMPT',
180-
'-dUseCIEColor', '-dTextAlphaBits=4',
181-
'-dGraphicsAlphaBits=4', '-dDOINTERPOLATE',
182-
'-sDEVICE=png16m', '-sOutputFile=%s' % pngfile,
183-
'-r%d' % dpi, pdffile]
178+
cmd = ["gs",
179+
"-dQUIET", "-dSAFER", "-dBATCH", "-dNOPAUSE", "-dNOPROMPT",
180+
"-dUseCIEColor", "-dTextAlphaBits=4",
181+
"-dGraphicsAlphaBits=4", "-dDOINTERPOLATE",
182+
"-sDEVICE=png16m", "-sOutputFile=%s" % pngfile,
183+
"-r%d" % dpi, pdffile]
184184
check_output(cmd, stderr=subprocess.STDOUT)
185185
return gs_convert
186186
raise RuntimeError("No suitable pdf to png renderer found")

lib/matplotlib/rcsetup.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
parameter set listed here should also be visited to the
1414
:file:`matplotlibrc.template` in matplotlib's root source directory.
1515
"""
16-
from __future__ import absolute_import, division, print_function
1716

1817
import six
1918

@@ -24,7 +23,8 @@
2423
import warnings
2524
import re
2625

27-
from matplotlib import cbook, testing
26+
import matplotlib as mpl
27+
from matplotlib import cbook
2828
from matplotlib.cbook import mplDeprecation, deprecated, ls_mapper
2929
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
3030
from matplotlib.colors import is_color_like
@@ -514,7 +514,12 @@ def validate_ps_distiller(s):
514514
elif s in ('false', False):
515515
return False
516516
elif s in ('ghostscript', 'xpdf'):
517-
return s
517+
if not mpl.get_executable_info("gs"):
518+
warnings.warn("Setting ps.usedistiller requires ghostscript.")
519+
return False
520+
if s == "xpdf" and not mpl.get_executable_info("pdftops"):
521+
warnings.warn("Setting ps.usedistiller to 'xpdf' requires xpdf.")
522+
return False
518523
else:
519524
raise ValueError('matplotlibrc ps.usedistiller must either be none, '
520525
'ghostscript or xpdf')

0 commit comments

Comments
 (0)