Skip to content

Make tests faster #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 5, 2012
Prev Previous commit
Next Next commit
Use python-ghostscript to convert PDF and EPS to PNG (if available).
  • Loading branch information
mdboom committed Jun 13, 2012
commit d638c9b5eed082e509cb6f39019be5a92af9ac1f
7 changes: 7 additions & 0 deletions doc/devel/coding_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ The following software is required to run the tests:

- `Inkscape <http://inkscape.org>`_ (to render SVG files)

For additional speed, you may also wish to install:

- `python-ghostscript <http://pypi.python.org/pypi/ghostscript>` (to
use ghostscript as a library from Python)::

pip install ghostscript

Running the tests
-----------------

Expand Down
37 changes: 26 additions & 11 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,32 @@ def convert(old, new):

return convert

if matplotlib.checkdep_ghostscript() is not None:
# FIXME: make checkdep_ghostscript return the command
if sys.platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
cmd = lambda old, new: \
[gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
'-sOutputFile=' + new, old]
converter['pdf'] = make_external_conversion_command(cmd)
converter['eps'] = make_external_conversion_command(cmd)
try:
import ghostscript
except ImportError:
if matplotlib.checkdep_ghostscript() is not None:
# FIXME: make checkdep_ghostscript return the command
if sys.platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
cmd = lambda old, new: \
[gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH', '-dSAFER',
'-sOutputFile=' + new, old]
converter['pdf'] = make_external_conversion_command(cmd)
converter['eps'] = make_external_conversion_command(cmd)
else:
def ghostscript_lib_converter(old, new):
args = [
'matplotlib', '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
'-dSAFER', '-sOutputFile=' + new, old]
try:
gs = ghostscript.Ghostscript(*args)
finally:
gs.exit()
ghostscript.cleanup()
converter['pdf'] = ghostscript_lib_converter
converter['eps'] = ghostscript_lib_converter

if matplotlib.checkdep_inkscape() is not None:
cmd = lambda old, new: \
Expand Down