@@ -430,50 +430,81 @@ def _get_data_path():
430430
431431
432432def checkdep_dvipng ():
433- stdin , stdout = os .popen4 ('dvipng -v' )
434- if 'This is dvipng' in stdout .read (): return True
435- else :
436- verbose .report ('dvipng not found!' , 'helpful' )
433+ try :
434+ stdin , stdout = os .popen4 ('dvipng -version' )
435+ line = stdout .readlines ()[1 ]
436+ v = line .split ()[- 1 ]
437+ float (v )
438+ if v >= '1.5' : return True
439+ else :
440+ verbose .report (line + '\n dvipng-1.5 or later not found!' , 'helpful' )
441+ return False
442+ except IndexError , ValueError :
443+ verbose .report (line + '\n dvipng-1.5 or later not found!' , 'helpful' )
437444 return False
438445
439446def checkdep_ghostscript ():
440- flag = False
441- if sys .platform == 'win32' :
442- stdin , stdout = os .popen4 ('gswin32c -v' )
443- if 'Ghostscript' in stdout .read (): flag = True
444- else :
445- stdin , stdout = os .popen4 ('gs -v' )
446- if 'Ghostscript' in stdout .read (): flag = True
447- if flag : return True
448- else :
449- verbose .report ('Ghostscript not found!\n \
450- Please install a recent version of ghostscript \n \
451- (gnu-ghostscript-8.16 or later suggested)\n ' , 'helpful' )
447+ try :
448+ if sys .platform == 'win32' :
449+ command = 'gswin32c -v'
450+ else :
451+ command = 'gs -v'
452+ stdin , stdout = os .popen4 (command )
453+ line = stdout .readlines ()[0 ]
454+ v = line .split ()[2 ]
455+ float (v )
456+ if v >= '8.16' : return True
457+ else :
458+ verbose .report (line + '\n Ghostscript-8.16 or later not found!\n ' , 'helpful' )
459+ return False
460+ except IndexError , ValueError :
461+ verbose .report (line + '\n Ghostscript-8.16 or later not found!\n ' , 'helpful' )
452462 return False
453463
454464def checkdep_ps2eps ():
455- stdin , stdout = os .popen4 ('ps2eps -v' )
456- if 'ps2eps - convert PostScript to EPS' in stdout .read (): return True
457- else :
458- verbose .report ('ps2eps not found!' , 'helpful' )
465+ try :
466+ stdin , stdout = os .popen4 ('ps2eps -v' )
467+ line = stdout .readlines ()[- 1 ]
468+ v = line .split ()[- 1 ]
469+ float (v )
470+ if v >= '1.58' : return True
471+ else :
472+ verbose .report (line + '\n ps2eps-1.58 or later not found!' , 'helpful' )
473+ return False
474+ except IndexError , ValueError :
475+ verbose .report (line + '\n ps2eps-1.58 or later not found!' , 'helpful' )
459476 return False
460477
461478def checkdep_tex ():
462- stdin , stdout = os .popen4 ('tex -v' )
463- if 'TeX' in stdout .read (): return True
464- else :
465- verbose .report ('latex not found!\
479+ try :
480+ stdin , stdout = os .popen4 ('tex -v' )
481+ line = stdout .readlines ()[0 ]
482+ v = line .split ()[1 ]
483+ float (v )
484+ if v >= '3.1415' : return True
485+ else :
486+ verbose .report (line + '\n TeX not found!\
487+ Please install the appropriate package for your platform.\n ' , 'helpful' )
488+ return False
489+ except IndexError , ValueError :
490+ verbose .report (line + '\n TeX not found!\
466491 Please install the appropriate package for your platform.\n ' , 'helpful' )
467492 return False
468493
469494def checkdep_xpdf ():
470- stdin , stdout = os .popen4 ('xpdf -v' )
471- if 'xpdf version' in stdout .read (): return True
472- else :
473- verbose .report ('xpdf not found!' , 'helpful' )
495+ try :
496+ stdin , stdout = os .popen4 ('xpdf -v' )
497+ line = stdout .readlines ()[0 ]
498+ v = line .split ()[- 1 ]
499+ float (v )
500+ if v >= 3.0 : return True
501+ else :
502+ verbose .report (line + '\n xpdf-3.0 or later not found!' , 'helpful' )
503+ return False
504+ except IndexError , ValueError :
505+ verbose .report (line + '\n xpdf-3.0 or later not found!' , 'helpful' )
474506 return False
475507
476-
477508def validate_path_exists (s ):
478509 'If s is a path, return s, else False'
479510 if os .path .exists (s ): return s
@@ -611,8 +642,6 @@ def validate_verbose_fileo(s):
611642 try : fileo = file (s , 'w' )
612643 except IOError :
613644 raise ValueError ('Verbose object could not open log file "%s" for writing.\n Check your matplotlibrc verbose.fileo setting' % s )
614-
615-
616645 else :
617646 verbose .fileo = fileo
618647 return verbose .fileo
@@ -633,27 +662,38 @@ def validate_ps_distiller(s):
633662 return False
634663 elif s == 'ghostscript' :
635664 if checkdep_ghostscript (): return s .lower ()
636- else : raise 'DependencyError' , 'matplotlibrc ps.usedistiller can not \
637- be set to ghostscript unless ghostscript is available on your system'
638- elif s == 'xpdf' :
639- if checkdep_ghostscript () and checkdep_xpdf () and checkdep_ps2eps ():
640- return s .lower ()
641665 else :
666+ raise 'DependencyError' , 'matplotlibrc ps.usedistiller can not be \
667+ set to ghostscript unless ghostscript-8.16 or later is available on your system'
668+ elif s == 'xpdf' :
669+ if not checkdep_ghostscript ():
670+ raise 'DependencyError' , 'matplotlibrc ps.usedistiller can not \
671+ be set to xpdf unless ghostscript-8.16 or later is available on your system'
672+ if not checkdep_xpdf ():
642673 raise 'DependencyError' , 'matplotlibrc ps.usedistiller can not \
643- be set to xpdf unless ghostscript, xpdf and ps2eps are available on your system'
674+ be set to xpdf unless xpdf-3.0 or later is available on your system'
675+ if not checkdep_ps2eps ():
676+ raise 'DependencyError' , 'matplotlibrc ps.usedistiller can not \
677+ be set to xpdf unless ps2eps-1.58 or later is available on your system'
678+ return s .lower ()
644679 else :
645- raise ValueError ('matplotlibrc ps.usedistiller must either be none, ghostscript or xpdf' )
680+ raise ValueError ('matplotlibrc ps.usedistiller must either be none,ghostscript or xpdf' )
646681
647682validate_tex_engine = ValidateInStrings (['tex' , 'latex' ], ignorecase = True )
648683
649684def validate_usetex (s ):
650685 bl = validate_bool (s )
651686 if bl :
652- if checkdep_tex () and checkdep_dvipng () and checkdep_ghostscript ():
653- return bl
654- else :
655- raise 'DependencyError' , 'matplotlibrc tex.usetex can not be set to \
656- True unless LaTeX, dvipng and ghostscript are available on your system.'
687+ if not checkdep_tex ():
688+ raise 'DependencyError' , 'matplotlibrc text.usetex can not \
689+ be set to True unless TeX/LaTeX is available on your system'
690+ if not checkdep_dvipng ():
691+ raise 'DependencyError' , 'matplotlibrc text.usetex can not \
692+ be set to True unless dvipng-1.5 or later is available on your system'
693+ if not checkdep_ghostscript ():
694+ raise 'DependencyError' , 'matplotlibrc text.usetex can not \
695+ be set to True unless ghostscript-8.16 or later is available on your system'
696+ return bl
657697 else : return bl
658698
659699validate_joinstyle = ValidateInStrings (['miter' , 'round' , 'bevel' ], ignorecase = True )
0 commit comments