|
15 | 15 | """ |
16 | 16 | from collections.abc import Iterable, Mapping |
17 | 17 | from functools import reduce |
| 18 | +import logging |
18 | 19 | import operator |
19 | 20 | import os |
20 | 21 | import re |
21 | 22 |
|
| 23 | +import matplotlib as mpl |
22 | 24 | from matplotlib import cbook |
23 | 25 | from matplotlib.cbook import ls_mapper |
24 | 26 | from matplotlib.fontconfig_pattern import parse_fontconfig_pattern |
|
28 | 30 | from cycler import Cycler, cycler as ccycler |
29 | 31 |
|
30 | 32 |
|
| 33 | +_log = logging.getLogger(__name__) |
31 | 34 | # The capitalized forms are needed for ipython at present; this may |
32 | 35 | # change for later versions. |
33 | 36 | interactive_bk = ['GTK3Agg', 'GTK3Cairo', |
@@ -534,11 +537,22 @@ def update_savefig_format(value): |
534 | 537 | def validate_ps_distiller(s): |
535 | 538 | if isinstance(s, str): |
536 | 539 | s = s.lower() |
537 | | - if s in ('none', None): |
| 540 | + if s in ('none', None, 'false', False): |
538 | 541 | return None |
539 | | - elif s in ('false', False): |
540 | | - return False |
541 | 542 | elif s in ('ghostscript', 'xpdf'): |
| 543 | + try: |
| 544 | + mpl._get_executable_info("gs") |
| 545 | + except FileNotFoundError: |
| 546 | + _log.warning("Setting rcParams['ps.usedistiller'] requires " |
| 547 | + "ghostscript.") |
| 548 | + return None |
| 549 | + if s == "xpdf": |
| 550 | + try: |
| 551 | + mpl._get_executable_info("pdftops") |
| 552 | + except FileNotFoundError: |
| 553 | + _log.warning("Setting rcParams['ps.usedistiller'] to 'xpdf' " |
| 554 | + "requires xpdf.") |
| 555 | + return None |
542 | 556 | return s |
543 | 557 | else: |
544 | 558 | raise ValueError('matplotlibrc ps.usedistiller must either be none, ' |
|
0 commit comments