import os import SCons.Errors import SCons.Defaults import glob Import('env') #env.Append(CCFLAGS = ' -DBOOST_PYTHON_DYNAMIC_LIB') #boost python prefix = env['PREFIX'] boost_root = env['BOOST_ROOT'] python_root = env['PYTHON_ROOT'] python_version = env['PYTHON_VERSION'] python_headers = python_root+'/include/python'+python_version boost_python_src_dir = boost_root + '/libs/python/src/' boost_python_src = glob.glob(boost_python_src_dir + '*.cpp') boost_python_src.append(glob.glob(boost_python_src_dir + 'object/*.cpp')) boost_python_src.append(glob.glob(boost_python_src_dir + 'converter/*.cpp')) python_cpppath = python_root+'/include/python'+python_version lib_boost_python = env.SharedLibrary('libboost-python',boost_python_src,CPPPATH=[boost_root,python_cpppath]) env.Install(prefix + '/lib',lib_boost_python) agg_root = env['AGG_ROOT'] agg_headers = agg_root +'/include' freetype2_root = env['FREETYPE2_ROOT'] def createPythonExtBuilder(env): """This is a utility function that creates boost-python etxension Builder in an Environment if it is not there already. If it is already there, we return the existing one. """ try: python_ext = env['BUILDERS']['PythonExtension'] except KeyError: action_list = [ SCons.Defaults.SharedCheck, SCons.Defaults.ShLinkAction ] python_ext = SCons.Builder.Builder(action = action_list, emitter = "$SHLIBEMITTER", prefix = '', suffix = '$SHLIBSUFFIX', target_scanner = SCons.Defaults.ProgScan, src_suffix = '$SHOBJSUFFIX', src_builder = 'SharedObject') env['BUILDERS']['PythonExtension'] = python_ext return python_ext createPythonExtBuilder(env) mapnik_python_src=Split( """ mapnik_color.cpp mapnik_envelope.cpp mapnik_image.cpp mapnik_layer.cpp mapnik_map.cpp mapnik_parameters.cpp mapnik_filter.cpp mapnik_rule.cpp mapnik_style.cpp mapnik_stroke.cpp mapnik_datasource_cache.cpp mapnik_python.cpp """ ) headers =[ '#include',boost_root,freetype2_root,agg_headers,python_headers] libraries=['mapnik','agg','boost-filesystem','boost-regex','boost-python'] libpaths = [prefix+"/lib",'#agg'] mapnik_python = env.PythonExtension(target='mapnik',source=mapnik_python_src,CPPPATH=headers,LIBS=libraries,LIBPATH=libpaths) env.Alias(target="install",source=env.Install(prefix+'/lib',mapnik_python))