2424import warnings
2525def _fn_name (): return sys ._getframe (1 ).f_code .co_name
2626
27- from matplotlib .backend_bases import RendererBase , GraphicsContextBase ,\
28- FigureManagerBase , FigureCanvasBase
29- from matplotlib .cbook import enumerate , izip
30- from matplotlib .figure import Figure
31- from matplotlib .mathtext import math_parse_s_ft2font
32- import matplotlib .numerix as numx
33- from matplotlib .transforms import Bbox
34-
3527import cairo
36-
3728_version_required = (0 ,9 ,0 )
3829if cairo .version_info < _version_required :
3930 raise SystemExit ("Pycairo %d.%d.%d is installed\n "
@@ -42,6 +33,15 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
4233backend_version = cairo .version
4334del _version_required
4435
36+ from matplotlib .backend_bases import RendererBase , GraphicsContextBase ,\
37+ FigureManagerBase , FigureCanvasBase
38+ from matplotlib .cbook import enumerate , izip
39+ from matplotlib .figure import Figure
40+ from matplotlib .mathtext import math_parse_s_ft2font
41+ import matplotlib .numerix as numx
42+ from matplotlib .transforms import Bbox
43+
44+
4545if hasattr (cairo .ImageSurface , 'create_for_array' ):
4646 HAVE_CAIRO_NUMPY = True
4747else :
@@ -588,9 +588,15 @@ def _save_ps_pdf (self, figure, filename, ext, orientation):
588588 width_in_points )
589589
590590 if ext == 'ps' :
591+ if not cairo .HAS_PS_SURFACE :
592+ raise RuntimeError ('cairo has not been compiled with PS '
593+ 'support enabled' )
591594 surface = cairo .PSSurface (filename , width_in_points ,
592595 height_in_points )
593596 else : # pdf
597+ if not cairo .HAS_PDF_SURFACE :
598+ raise RuntimeError ('cairo has not been compiled with PDF '
599+ 'support enabled' )
594600 surface = cairo .PDFSurface (filename , width_in_points ,
595601 height_in_points )
596602 # surface.set_dpi() can be used
0 commit comments