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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
#!/usr/bin/env python
import sys
import os
import re
import platform
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import dict_append, get_info
agg_dir = 'agg-24'
agg_lib = 'agg24_src'
config = Configuration('agg', parent_package,top_path)
numerix_info = get_info('numerix')
if ('NUMPY', None) in numerix_info.get('define_macros',[]):
dict_append(numerix_info,
define_macros = [('PY_ARRAY_TYPES_PREFIX','NUMPY_CXX'),
('OWN_DIMENSIONS','0'),
('OWN_STRIDES','0')])
#-------------------------------------------------------------------------
# Configure the Agg backend to use on each platform
#-------------------------------------------------------------------------
if sys.platform=='win32':
plat = 'win32'
elif sys.platform == 'darwin':
plat = 'gl'
else:
#plat = 'gtk1' # use with gtk1, it's fast
plat = 'x11' # use with gtk2, it's slow but reliable
#plat = 'gdkpixbuf2'
#-------------------------------------------------------------------------
# Add the Agg sources
#-------------------------------------------------------------------------
agg_include_dirs = [agg_dir+'/include',agg_dir+'/font_freetype'] + ["/usr/include/freetype2/"]
agg_sources = [agg_dir+'/src/*.cpp',
agg_dir+'/font_freetype/*.cpp']
config.add_library(agg_lib,
agg_sources,
include_dirs = agg_include_dirs,
depends = [agg_dir])
#-------------------------------------------------------------------------
# Add the Kiva sources
#-------------------------------------------------------------------------
if sys.platform == 'darwin':
define_macros = [('__DARWIN__', None)]
macros = [('__DARWIN__', None)]
extra_link_args = ['-framework', 'Carbon', '-Wl,-search_paths_first']
else:
define_macros = []
macros = []
extra_link_args = []
kiva_include_dirs = ['src'] + agg_include_dirs
config.add_library('kiva_src',
['src/kiva_*.cpp', 'src/gl_graphics_context.cpp'],
include_dirs = kiva_include_dirs,
# Use "macros" instead of "define_macros" because the
# latter is only used for extensions, and not clibs
macros = macros,
)
# MSVC6.0: uncomment to handle template parameters:
#extra_compile_args = ['/Zm1000']
extra_compile_args = []
# XXX: test whether numpy has weakref support
#-------------------------------------------------------------------------
# Build the extension itself
#-------------------------------------------------------------------------
# Check for g++ < 4.0 on 64-bit Linux
use_32bit_workaround = False
if sys.platform == 'linux2' and '64bit' in platform.architecture():
f = os.popen("g++ --version")
line0 = f.readline()
f.close()
m = re.match(r'.+?\s(3|4)\.\d+', line0)
if int(m.group(1)) < 4:
use_32bit_workaround = True
# Enable workaround of agg bug on 64-bit machines with g++ < 4.0
if use_32bit_workaround:
define_macros.append(("ALWAYS_32BIT_WORKAROUND", 1))
# Options to make OS X link OpenGL
darwin_opengl_opts = dict(
include_dirs = [
'/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x
for x in ['Carbon', 'ApplicationServices', 'OpenGL']],
define_macros = [('__DARWIN__',None)],
extra_link_args =
['-framework %s' % x
for x in ['Carbon', 'ApplicationServices', 'OpenGL']]
)
build_info = {}
kiva_lib = 'kiva_src'
build_libraries = [kiva_lib, agg_lib, "freetype", "X11"]
if sys.platform == "win32":
build_libraries += ["opengl32", "glu32"]
elif sys.platform == "darwin":
dict_append(build_info, **darwin_opengl_opts)
else:
# This should work for most linuxes (linuces?)
build_libraries += ["GL", "GLU"]
dict_append(build_info,
sources = ['agg.i'],
include_dirs = kiva_include_dirs,
libraries = build_libraries,
depends = ['src/*.[ih]'],
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args,
define_macros=define_macros,
)
dict_append(build_info, **numerix_info)
config.add_extension('_agg', **build_info)
sources = [os.path.join('src',plat,'plat_support.i'),
os.path.join('src',plat,'agg_bmp.cpp'),
]
if plat != 'gl':
sources.append(os.path.join('src',plat,'agg_platform_specific.cpp'))
plat_info = {}
dict_append(plat_info, libraries = [agg_lib],
include_dirs = kiva_include_dirs,
extra_compile_args = extra_compile_args,
depends = ['src'])
dict_append(plat_info, **numerix_info)
if plat=='win32':
dict_append(plat_info, libraries = ['gdi32','user32'])
elif plat in ['x11','gtk1']:
# Make sure we raise an error if the information is not found.
# Frequently, the 64-bit libraries are not in a known location and need
# manual configuration. From experience, this is usually not detected by
# the builder if we do not raise an exception.
x11_info = get_info('x11', notfound_action=2)
dict_append(plat_info, **x11_info)
dict_append(plat_info, libraries = ['X11'])
elif plat=='gdkpixbuf2':
#gdk_pixbuf_xlib_2 = get_info('gdk_pixbuf_xlib_2',notfound_action=1)
#dict_append(plat_info,**gdk_pixbuf_xlib_2)
gtk_info = get_info('gtk+-2.0')
dict_append(plat_info, **gtk_info)
#x11_info = get_info('x11',notfound_action=1)
#dict_append(plat_info,**x11_info)
elif plat == 'gl':
if sys.platform == 'darwin':
dict_append(plat_info, **darwin_opengl_opts)
else:
msg = "OpenGL build support only on MacOSX right now."
raise NotImplementedError, msg
config.add_extension('_plat_support',
sources,
**plat_info
)
config.add_data_dir('tests')
config.add_data_files('*.txt', '*.bat')
return config
|