From 7c5693c169d8805b86be69b02056e51c2089557f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 14 Jan 2013 16:07:38 -0800 Subject: [PATCH] scons: make python includes a list and sensitive to platform specific directories - closes #1691 and fixes mapnik/mapnik-packaging#66 --- SConstruct | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 47ae0eb92..cfc77df43 100644 --- a/SConstruct +++ b/SConstruct @@ -963,6 +963,7 @@ if not preconfigured: env['PLUGINS'] = PLUGINS env['EXTRA_FREETYPE_LIBS'] = [] env['SQLITE_LINKFLAGS'] = [] + env['PYTHON_INCLUDES'] = [] # previously a leading / was expected for LIB_DIR_NAME # now strip it to ensure expected behavior if env['LIB_DIR_NAME'].startswith(os.path.sep): @@ -1350,7 +1351,14 @@ if not preconfigured: py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON'] else: py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON'] - env['PYTHON_INCLUDES'] = call(py_includes) + env['PYTHON_INCLUDES'].append(call(py_includes)) + + # also append platform specific includes + if py3: + py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc(plat_specific=True))"''' % env['PYTHON'] + else: + py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc(plat_specific=True)"''' % env['PYTHON'] + env['PYTHON_INCLUDES'].append(call(py_plat_includes)) # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location if py3: @@ -1361,7 +1369,7 @@ if not preconfigured: else: env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip() env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3] - env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION'] + env['PYTHON_INCLUDES'] = [env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']] env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' # if user-requested custom prefix fall back to manual concatenation for building subdirectories @@ -1527,7 +1535,8 @@ if not preconfigured: # as they are later set in the python build.py # ugly hack needed until we have env specific conf backup = env.Clone().Dictionary() - env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES'])) + for pyinc in env['PYTHON_INCLUDES']: + env.AppendUnique(CPPPATH = os.path.realpath(pyinc)) if not conf.CheckHeader(header='Python.h',language='C'): color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])