1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
--- setup.py
+++ setup.py
@@ -29,6 +30,16 @@
print pipe.stderr.read()
raise SystemExit('Error: %s >= %s not found' % (pkg, version))
+def pkg_config_svg_check():
+ if os.environ.get('PYCAIRO_DISABLE_SVG', None) is None:
+ pipe = call('pkg-config --exists cairo-svg')
+ if pipe.returncode == 0:
+ return [('PYCAIRO_ENABLE_SVG', None)]
+ else:
+ return []
+ else:
+ return []
+
def pkg_config_parse(opt, pkg):
pipe = call("pkg-config %s %s" % (opt, pkg))
output = pipe.stdout.read()
@@ -94,6 +105,7 @@
'src/pattern.c',
'src/surface.c',
],
+ define_macros = pkg_config_svg_check(),
include_dirs = pkg_config_parse('--cflags-only-I', 'cairo'),
library_dirs = pkg_config_parse('--libs-only-L', 'cairo'),
libraries = pkg_config_parse('--libs-only-l', 'cairo'),
--- src/cairomodule.c
+++ src/cairomodule.c
@@ -122,7 +122,7 @@
#else
0,
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
&PycairoSVGSurface_Type,
#else
0,
@@ -209,7 +209,7 @@
if (PyType_Ready(&PycairoPSSurface_Type) < 0)
return;
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
if (PyType_Ready(&PycairoSVGSurface_Type) < 0)
return;
#endif
@@ -285,7 +285,7 @@
PyModule_AddObject(m, "PSSurface", (PyObject *)&PycairoPSSurface_Type);
#endif
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
Py_INCREF(&PycairoSVGSurface_Type);
PyModule_AddObject(m, "SVGSurface", (PyObject *)&PycairoSVGSurface_Type);
#endif
@@ -350,7 +350,7 @@
#else
PyModule_AddIntConstant(m, "HAS_PS_SURFACE", 0);
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 1);
#else
PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 0);
--- src/private.h
+++ src/private.h
@@ -86,7 +86,7 @@
extern PyTypeObject PycairoPSSurface_Type;
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
extern PyTypeObject PycairoSVGSurface_Type;
#endif
--- src/pycairo.h
+++ src/pycairo.h
@@ -178,7 +178,7 @@
#define PycairoPSSurface_Type *(Pycairo_CAPI->PSSurface_Type)
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
#define PycairoSVGSurface_Type *(Pycairo_CAPI->SVGSurface_Type)
#endif
--- src/surface.c
+++ src/surface.c
@@ -80,7 +80,7 @@
type = &PycairoPSSurface_Type;
break;
#endif
-#if CAIRO_HAS_SVG_SURFACE
+#if PYCAIRO_ENABLE_SVG
case CAIRO_SURFACE_TYPE_SVG:
type = &PycairoSVGSurface_Type;
break;
@@ -965,7 +965,7 @@
/* Class SVGSurface(Surface) ----------------------------------------------- */
-#ifdef CAIRO_HAS_SVG_SURFACE
+#ifdef PYCAIRO_ENABLE_SVG
#include <cairo-svg.h>
static PyObject *
@@ -1067,7 +1067,7 @@
0, /* tp_is_gc */
0, /* tp_bases */
};
-#endif /* CAIRO_HAS_SVG_SURFACE */
+#endif /* PYCAIRO_ENABLE_SVG */
/* Class Win32Surface(Surface) -------------------------------------------- */
|