44import warnings
55import distutils .version as version
66
7+ tex_req = '3.1415'
8+ gs_req = '7.07'
9+ gs_sugg = '8.60'
10+ dvipng_req = '1.5'
11+ pdftops_req = '3.0'
12+
713def dvipng ():
814 try :
915 stdin , stdout = os .popen4 ('dvipng -version' )
10- line = stdout .readlines ()[1 ]
11- v = line .split ()[- 1 ]
12- float (v )
13- return v
16+ return stdout .readlines ()[1 ].split ()[- 1 ]
1417 except (IndexError , ValueError ):
1518 return None
1619
1720def ghostscript ():
1821 try :
1922 if sys .platform == 'win32' :
20- command = 'gswin32c -v '
23+ command = 'gswin32c --version '
2124 else :
22- command = 'gs -v '
25+ command = 'gs --version '
2326 stdin , stdout = os .popen4 (command )
24- line = stdout .readlines ()[0 ]
25- v = line .split ()[- 2 ]
26- vtest = '.' .join (v .split ('.' )[:2 ]) # deal with version numbers like '7.07.1'
27- float (vtest )
28- return vtest
27+ return stdout .read ()[:- 1 ]
2928 except (IndexError , ValueError ):
3029 return None
3130
@@ -35,9 +34,7 @@ def tex():
3534 line = stdout .readlines ()[0 ]
3635 pattern = '3\.1\d+'
3736 match = re .search (pattern , line )
38- v = match .group (0 )
39- float (v )
40- return v
37+ return match .group (0 )
4138 except (IndexError , ValueError ):
4239 return None
4340
@@ -46,9 +43,7 @@ def pdftops():
4643 stdin , stdout = os .popen4 ('pdftops -v' )
4744 for line in stdout .readlines ():
4845 if 'version' in line :
49- v = line .split ()[- 1 ]
50- float (v )
51- return v
46+ return line .split ()[- 1 ]
5247 except (IndexError , ValueError ):
5348 return None
5449
@@ -66,8 +61,6 @@ def ps_distiller(s):
6661 return False
6762
6863 flag = True
69- gs_req = '7.07'
70- gs_sugg = '7.07'
7164 gs_v = ghostscript ()
7265 if compare_versions (gs_v , gs_sugg ): pass
7366 elif compare_versions (gs_v , gs_req ):
@@ -81,14 +74,13 @@ def ps_distiller(s):
8174 'system.' ) % gs_req )
8275
8376 if s == 'xpdf' :
84- pdftops_req = '3.0'
8577 pdftops_v = pdftops ()
8678 if compare_versions (pdftops_v , pdftops_req ): pass
8779 else :
8880 flag = False
8981 warnings .warn (('matplotlibrc ps.usedistiller can not be set to '
90- 'xpdf unless xpdf -%s or later is installed on your '
91- 'system.' ) % pdftops_req )
82+ 'xpdf unless pdftops -%s or later is installed on '
83+ 'your system.' ) % pdftops_req )
9284
9385 if flag :
9486 return s
@@ -99,10 +91,6 @@ def usetex(s):
9991 if not s :
10092 return False
10193
102- tex_req = '3.1415'
103- gs_req = '7.07'
104- gs_sugg = '7.07'
105- dvipng_req = '1.5'
10694 flag = True
10795
10896 tex_v = tex ()
0 commit comments