Skip to content

Commit

Permalink
Merge pull request #6763 from mdboom/invalidate-cache-ghostscript
Browse files Browse the repository at this point in the history
TST: Invalidate test cache on gs/inkscape version
  • Loading branch information
tacaswell committed Jul 16, 2016
2 parents 133701c + b940775 commit b2a8b2c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
65 changes: 36 additions & 29 deletions lib/matplotlib/__init__.py
Expand Up @@ -365,23 +365,27 @@ def checkdep_dvipng():


def checkdep_ghostscript():
if sys.platform == 'win32':
# mgs is the name in miktex
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
else:
gs_execs = ['gs']
for gs_exec in gs_execs:
try:
s = subprocess.Popen(
[gs_exec, '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate()
if s.returncode == 0:
v = stdout[:-1].decode('ascii')
return gs_exec, v
except (IndexError, ValueError, OSError):
pass
return None, None
if checkdep_ghostscript.executable is None:
if sys.platform == 'win32':
# mgs is the name in miktex
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
else:
gs_execs = ['gs']
for gs_exec in gs_execs:
try:
s = subprocess.Popen(
[gs_exec, '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate()
if s.returncode == 0:
v = stdout[:-1].decode('ascii')
checkdep_ghostscript.executable = gs_exec
checkdep_ghostscript.version = v
except (IndexError, ValueError, OSError):
pass
return checkdep_ghostscript.executable, checkdep_ghostscript.version
checkdep_ghostscript.executable = None
checkdep_ghostscript.version = None


def checkdep_tex():
Expand Down Expand Up @@ -413,18 +417,21 @@ def checkdep_pdftops():


def checkdep_inkscape():
try:
s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate()
lines = stdout.decode('ascii').split('\n')
for line in lines:
if 'Inkscape' in line:
v = line.split()[1]
break
return v
except (IndexError, ValueError, UnboundLocalError, OSError):
return None
if checkdep_inkscape.version is None:
try:
s = subprocess.Popen(['inkscape', '-V'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate()
lines = stdout.decode('ascii').split('\n')
for line in lines:
if 'Inkscape' in line:
v = line.split()[1]
break
checkdep_inkscape.version = v
except (IndexError, ValueError, UnboundLocalError, OSError):
pass
return checkdep_inkscape.version
checkdep_inkscape.version = None


def checkdep_xmllint():
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/testing/compare.py
Expand Up @@ -99,6 +99,14 @@ def get_file_hash(path, block_size=2 ** 20):
if not data:
break
md5.update(data)

if path.endswith('.pdf'):
from matplotlib import checkdep_ghostscript
md5.update(checkdep_ghostscript()[1].encode('utf-8'))
elif path.endswith('.svg'):
from matplotlib import checkdep_inkscape
md5.update(checkdep_inkscape().encode('utf-8'))

return md5.hexdigest()


Expand Down

0 comments on commit b2a8b2c

Please sign in to comment.