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

Skip to content

Commit b9eeb44

Browse files
committed
Invalidate test cache on gs/inkscape version
1 parent c718e61 commit b9eeb44

File tree

2 files changed

+44
-29
lines changed

2 files changed

+44
-29
lines changed

lib/matplotlib/__init__.py

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -365,23 +365,27 @@ def checkdep_dvipng():
365365

366366

367367
def checkdep_ghostscript():
368-
if sys.platform == 'win32':
369-
# mgs is the name in miktex
370-
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
371-
else:
372-
gs_execs = ['gs']
373-
for gs_exec in gs_execs:
374-
try:
375-
s = subprocess.Popen(
376-
[gs_exec, '--version'], stdout=subprocess.PIPE,
377-
stderr=subprocess.PIPE)
378-
stdout, stderr = s.communicate()
379-
if s.returncode == 0:
380-
v = stdout[:-1].decode('ascii')
381-
return gs_exec, v
382-
except (IndexError, ValueError, OSError):
383-
pass
384-
return None, None
368+
if checkdep_ghostscript.executable is None:
369+
if sys.platform == 'win32':
370+
# mgs is the name in miktex
371+
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
372+
else:
373+
gs_execs = ['gs']
374+
for gs_exec in gs_execs:
375+
try:
376+
s = subprocess.Popen(
377+
[gs_exec, '--version'], stdout=subprocess.PIPE,
378+
stderr=subprocess.PIPE)
379+
stdout, stderr = s.communicate()
380+
if s.returncode == 0:
381+
v = stdout[:-1].decode('ascii')
382+
checkdep_ghostscript.executable = gs_exec
383+
checkdep_ghostscript.version = v
384+
except (IndexError, ValueError, OSError):
385+
pass
386+
return checkdep_ghostscript.executable, checkdep_ghostscript.version
387+
checkdep_ghostscript.executable = None
388+
checkdep_ghostscript.version = None
385389

386390

387391
def checkdep_tex():
@@ -413,18 +417,21 @@ def checkdep_pdftops():
413417

414418

415419
def checkdep_inkscape():
416-
try:
417-
s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE,
418-
stderr=subprocess.PIPE)
419-
stdout, stderr = s.communicate()
420-
lines = stdout.decode('ascii').split('\n')
421-
for line in lines:
422-
if 'Inkscape' in line:
423-
v = line.split()[1]
424-
break
425-
return v
426-
except (IndexError, ValueError, UnboundLocalError, OSError):
427-
return None
420+
if checkdep_inkscape.version is None:
421+
try:
422+
s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE,
423+
stderr=subprocess.PIPE)
424+
stdout, stderr = s.communicate()
425+
lines = stdout.decode('ascii').split('\n')
426+
for line in lines:
427+
if 'Inkscape' in line:
428+
v = line.split()[1]
429+
break
430+
checkdep_inkscape.version = v
431+
except (IndexError, ValueError, UnboundLocalError, OSError):
432+
pass
433+
return checkdep_inkscape.version
434+
checkdep_inkscape.version = None
428435

429436

430437
def checkdep_xmllint():

lib/matplotlib/testing/compare.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ def get_file_hash(path, block_size=2 ** 20):
9999
if not data:
100100
break
101101
md5.update(data)
102+
103+
if path.endswith('.pdf'):
104+
from matplotlib import checkdep_ghostscript
105+
md5.update(checkdep_ghostscript()[1])
106+
elif path.endswith('.svg'):
107+
from matplotlib import checkdep_inkscape
108+
md5.update(checkdep_inkscape())
109+
102110
return md5.hexdigest()
103111

104112

0 commit comments

Comments
 (0)