Skip to content

Commit 787a38f

Browse files
committed
Make requirements of usetex=True reflect those documented in
texmanager.py. (No need to require ghostscript if using dvipng and vice-versa.) -ADS svn path=/trunk/matplotlib/; revision=1965
1 parent 77d3825 commit 787a38f

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

lib/matplotlib/__init__.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ def checkdep_ghostscript():
452452
stdin, stdout = os.popen4(command)
453453
line = stdout.readlines()[0]
454454
v = line.split()[2]
455-
float(v)
455+
vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1'
456+
float(vtest)
456457
if v >= '8.16': return True
457458
else:
458459
verbose.report(line+'\nGhostscript-8.16 or later not found!\n', 'helpful')
@@ -479,9 +480,12 @@ def checkdep_tex():
479480
try:
480481
stdin, stdout = os.popen4('tex -v')
481482
line = stdout.readlines()[0]
482-
v = line.split()[1]
483-
float(v)
484-
if v >= '3.1415': return True
483+
v = 0.0 # no version installed until we find one...
484+
for potential_version_numstr in line.split():
485+
if potential_version_numstr.startswith('3.1'):
486+
v=float(potential_version_numstr)
487+
break # found version number
488+
if v >= 3.1415: return True
485489
else:
486490
verbose.report(line+'\nTeX not found!\
487491
Please install the appropriate package for your platform.\n', 'helpful')
@@ -688,13 +692,14 @@ def validate_usetex(s):
688692
raise 'DependencyError', 'matplotlibrc text.usetex can not \
689693
be set to True unless TeX/LaTeX is available on your system'
690694
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'
695+
warnings.warn( 'matplotlibrc text.usetex can not \
696+
be be used with *Agg backend unless dvipng-1.5 or later is available on your system' )
693697
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'
698+
warnings.warn('matplotlibrc text.usetex can not \
699+
be be used with ps backend unless ghostscript-8.16 or later is available on your system')
700+
return bl
701+
else:
696702
return bl
697-
else: return bl
698703

699704
validate_joinstyle = ValidateInStrings(['miter', 'round', 'bevel'], ignorecase=True)
700705

@@ -942,7 +947,7 @@ def matplotlib_fname():
942947

943948

944949

945-
def rc_params():
950+
def rc_params(fail_on_error=False):
946951
'Return the default params updated from the values in the rc file'
947952

948953
deprecated_map = {
@@ -990,13 +995,18 @@ def rc_params():
990995
ind = val.find('#')
991996
if ind>=0: val = val[:ind] # ignore trailing comments
992997
val = val.strip()
993-
try: cval = converter(val) # try to convert to proper type or raise
994-
except Exception, msg:
995-
warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg))
996-
continue
997-
else:
998-
# Alles Klar, update dict
998+
if fail_on_error:
999+
cval = converter(val) # try to convert to proper type or raise
9991000
defaultParams[key][0] = cval
1001+
else:
1002+
try: cval = converter(val) # try to convert to proper type or raise
1003+
except Exception, msg:
1004+
warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (
1005+
val, cnt, line, fname, msg))
1006+
continue
1007+
else:
1008+
# Alles Klar, update dict
1009+
defaultParams[key][0] = cval
10001010

10011011
# strip the conveter funcs and return
10021012
ret = dict([ (key, tup[0]) for key, tup in defaultParams.items()])

0 commit comments

Comments
 (0)