From 65b03a323081d6f5ed4826fe2ed89a9250341a64 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 20 Jul 2012 13:56:21 -0700 Subject: [PATCH] scons: try to unbreak boost_python lib check on linux --- SConstruct | 106 ++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 54 deletions(-) diff --git a/SConstruct b/SConstruct index 0a5053b5a..60c68a83b 100644 --- a/SConstruct +++ b/SConstruct @@ -1331,9 +1331,60 @@ if not preconfigured: color_print(4,'Not building with cairo support, pass CAIRO=True to enable') if 'python' in env['BINDINGS']: + if not os.access(env['PYTHON'], os.X_OK): + color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) + Exit(1) py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip() + if py3: + sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON'] + else: + sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] + env['PYTHON_SYS_PREFIX'] = call(sys_prefix) + + if HAS_DISTUTILS: + if py3: + sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON'] + else: + sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] + env['PYTHON_VERSION'] = call(sys_version) + + if py3: + 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) + + # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location + if py3: + site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON'] + else: + site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] + env['PYTHON_SITE_PACKAGES'] = call(site_packages) + 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_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 + if env['PYTHON_PREFIX']: + py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' + env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install + else: + env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES'] + + if py3: + is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON'] + else: + is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON'] + + if is_64_bit: + env['PYTHON_IS_64BIT'] = True + else: + env['PYTHON_IS_64BIT'] = False + if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python': env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND'] elif env['BOOST_PYTHON_LIB'] == 'boost_python': @@ -1343,7 +1394,7 @@ if not preconfigured: color_print(1,'Could not find required header files for boost python') env['MISSING_DEPS'].append('boost python') - if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB']], header='boost/python/detail/config.hpp', language='C++'): + if not conf.CheckLibWithHeader(libs=[env['BOOST_PYTHON_LIB'],'python%s' % env['PYTHON_VERSION']], header='boost/python/detail/config.hpp', language='C++'): color_print(1, 'Could not find library "%s" for boost python bindings' % env['BOOST_PYTHON_LIB']) # failing on launchpad, so let's make it a warning for now #env['MISSING_DEPS'].append('boost python') @@ -1481,60 +1532,7 @@ if not preconfigured: env.Append(CXXFLAGS = '-fcatch-undefined-behavior -ftrapv -fwrapv') if 'python' in env['BINDINGS']: - if not os.access(env['PYTHON'], os.X_OK): - color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) - Exit(1) - - if py3: - sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON'] - else: - sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] - env['PYTHON_SYS_PREFIX'] = call(sys_prefix) - - if HAS_DISTUTILS: - if py3: - sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON'] - else: - sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] - env['PYTHON_VERSION'] = call(sys_version) - - if py3: - 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) - - # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location - if py3: - site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON'] - else: - site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] - env['PYTHON_SITE_PACKAGES'] = call(site_packages) - 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_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 - if env['PYTHON_PREFIX']: - py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' - env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install - else: - env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES'] - - if py3: - is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON'] - else: - is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON'] - - if is_64_bit: - env['PYTHON_IS_64BIT'] = True - else: - env['PYTHON_IS_64BIT'] = False - majver, minver = env['PYTHON_VERSION'].split('.') - # we don't want the includes it in the main environment... # as they are later set in the python build.py # ugly hack needed until we have env specific conf