Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fef6842

Browse files
committed
improved ghostscript version checking
svn path=/trunk/matplotlib/; revision=4094
1 parent 5046eff commit fef6842

4 files changed

Lines changed: 19 additions & 34 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,11 @@ def checkdep_dvipng():
234234
def checkdep_ghostscript():
235235
try:
236236
if sys.platform == 'win32':
237-
command = 'gswin32c -v'
237+
command = 'gswin32c --version'
238238
else:
239-
command = 'gs -v'
239+
command = 'gs --version'
240240
stdin, stdout = os.popen4(command)
241-
line = stdout.readlines()[0]
242-
v = line.split()[-2]
241+
v = stdout.read()[:-1]
243242
vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1'
244243
float(vtest)
245244
return vtest

lib/matplotlib/config/checkdep.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,27 @@
44
import warnings
55
import 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+
713
def 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

1720
def 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()

lib/matplotlib/config/cutils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def _get_home():
5555
else:
5656
raise RuntimeError('please define environment variable $HOME')
5757

58-
59-
6058
get_home = verbose.wrap('$HOME=%s', _get_home, always=False)
6159

6260
def _get_configdir():
@@ -89,8 +87,8 @@ def _get_configdir():
8987
os.mkdir(p)
9088

9189
return p
92-
get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False)
9390

91+
get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False)
9492

9593
def _get_data_path():
9694
'get the path to matplotlib data'

lib/matplotlib/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ def set_text(self, s):
654654
self._text = '%s' % (s,)
655655

656656
def is_math_text(self, s):
657-
if rcParams['text.usetex']: return 'TeX'
657+
if rcParams['text.usetex']: return 'TeX'
658658

659659
# Did we find an even number of non-escaped dollar signs?
660660
# If so, treat is as math text.

0 commit comments

Comments
 (0)