Пример #1
0
def check_sqlite3(self, *k, **kw):
    root = k and k[0] or kw.get('path', None) or Options.options.with_sqlite3
    mandatory = kw.get('mandatory', True)
    var = kw.get('uselib_store', 'SQLITE3')

    if not self.options.with_sqlite_locking:
        conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)

    if root:
        self.check_cxx(lib='sqlite3',
                       msg='Checking for SQLite3 library',
                       define_name='HAVE_%s' % var,
                       uselib_store=var,
                       mandatory=mandatory,
                       includes="%s/include" % root,
                       libpath="%s/lib" % root)
    else:
        try:
            self.check_cfg(package='sqlite3',
                           args=['--cflags', '--libs'],
                           global_define=True,
                           define_name='HAVE_%s' % var,
                           uselib_store='SQLITE3',
                           mandatory=True)
        except:
            self.check_cxx(lib='sqlite3',
                           msg='Checking for SQLite3 library',
                           define_name='HAVE_%s' % var,
                           uselib_store=var,
                           mandatory=mandatory)
Пример #2
0
def set_variant(conf, variant, env):
    conf.msg('----------------------------------------', '----{ %s' % variant)
    conf.setenv(variant, env=env)
    compiler = FLAGS[conf.env.COMPILER_CXX]
    arch = 'arch_%d' % TARGETS[conf.env.TARGET]['arch']
    compiler_target = compiler[arch] if arch in compiler else None

    # Compiler options
    conf.env.CXXFLAGS = compiler['common'] + compiler[variant]
    if compiler_target and 'cxxflags' in compiler_target:
        conf.env.CXXFLAGS += compiler_target['cxxflags']

    # Linker options
    conf.env.LINKFLAGS = compiler['link_' + variant]
    if compiler_target and 'linkflags' in compiler_target:
        conf.env.LINKFLAGS += compiler_target['linkflags']

    # Includes and defines
    if conf.env.TARGET == 'windows_x86':
        conf.define('WIN32_LEAN_AND_MEAN', 1)
    if compiler_target and 'env' in compiler_target:
        for key, value in compiler_target['env'].items():
            conf.env[key] = value

    conf.env.MSVC_MANIFEST = False
Пример #3
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    pybin = conf.env["PYTHON"]
    if not pybin:
        conf.fatal("could not find the python executable")
    cmd = pybin + ["-c", "import sys\nfor x in sys.version_info: print(str(x))"]
    debug("python: Running python command %r" % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))
    result = (minver is None) or (pyver_tuple >= minver)
    if result:
        pyver = ".".join([str(x) for x in pyver_tuple[:2]])
        conf.env["PYTHON_VERSION"] = pyver
        if "PYTHONDIR" in conf.environ:
            pydir = conf.environ["PYTHONDIR"]
        else:
            if Utils.is_win32:
                (python_LIBDEST, pydir) = conf.get_python_variables(
                    [
                        "get_config_var('LIBDEST') or ''",
                        "get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"],
                    ],
                    ["from distutils.sysconfig import get_config_var, get_python_lib"],
                )
            else:
                python_LIBDEST = None
                (pydir,) = conf.get_python_variables(
                    ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
                    ["from distutils.sysconfig import get_python_lib"],
                )
            if python_LIBDEST is None:
                if conf.env["LIBDIR"]:
                    python_LIBDEST = os.path.join(conf.env["LIBDIR"], "python" + pyver)
                else:
                    python_LIBDEST = os.path.join(conf.env["PREFIX"], "lib", "python" + pyver)
        if "PYTHONARCHDIR" in conf.environ:
            pyarchdir = conf.environ["PYTHONARCHDIR"]
        else:
            (pyarchdir,) = conf.get_python_variables(
                ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
                ["from distutils.sysconfig import get_python_lib"],
            )
            if not pyarchdir:
                pyarchdir = pydir
        if hasattr(conf, "define"):
            conf.define("PYTHONDIR", pydir)
            conf.define("PYTHONARCHDIR", pyarchdir)
        conf.env["PYTHONDIR"] = pydir
        conf.env["PYTHONARCHDIR"] = pyarchdir
    pyver_full = ".".join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg("Checking for python version", pyver_full)
    else:
        minver_str = ".".join(map(str, minver))
        conf.msg("Checking for python version", pyver_tuple, ">= %s" % (minver_str,) and "GREEN" or "YELLOW")
    if not result:
        conf.fatal("The python version is too old, expecting %r" % (minver,))
Пример #4
0
def check_ssl(conf):
    if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
        libcrypto = conf.check_cc(lib='crypto',
                                  header_name='openssl/crypto.h',
                                  define_name='HAVE_SSL',
                                  uselib_store='SSL')
    else:
        conf.define("HAVE_SSL", 1)
    if not conf.get_define ("HAVE_SSL"):
        conf.fatal("Cannot find SSL libraries")
Пример #5
0
def check_sferes(conf):
	if conf.options.sferes:
		conf.env.INCLUDES_SFERES = [conf.options.sferes]
		conf.env.LIBPATH_SFERES = [conf.options.sferes + '/build/default/sferes']
        try:
                res = conf.find_file('sferes/ea/ea.hpp', conf.env.INCLUDES_SFERES)
                conf.define("USE_SFERES", 1)
        except:
                print 'SFERES not found'
	return 1
Пример #6
0
def check_python_version(conf,minver=None):
	assert minver is None or isinstance(minver,tuple)
	pybin=conf.env['PYTHON']
	if not pybin:
		conf.fatal('could not find the python executable')
	cmd=pybin+['-c','import sys\nfor x in sys.version_info: print(str(x))']
	Logs.debug('python: Running python command %r'%cmd)
	lines=conf.cmd_and_log(cmd).split()
	assert len(lines)==5,"found %i lines, expected 5: %r"%(len(lines),lines)
	pyver_tuple=(int(lines[0]),int(lines[1]),int(lines[2]),lines[3],int(lines[4]))
	result=(minver is None)or(pyver_tuple>=minver)
	if result:
		pyver='.'.join([str(x)for x in pyver_tuple[:2]])
		conf.env['PYTHON_VERSION']=pyver
		if'PYTHONDIR'in conf.env:
			pydir=conf.env['PYTHONDIR']
		elif'PYTHONDIR'in conf.environ:
			pydir=conf.environ['PYTHONDIR']
		else:
			if Utils.is_win32:
				(python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0) or ''"])
			else:
				python_LIBDEST=None
				(pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0) or ''"])
			if python_LIBDEST is None:
				if conf.env['LIBDIR']:
					python_LIBDEST=os.path.join(conf.env['LIBDIR'],"python"+pyver)
				else:
					python_LIBDEST=os.path.join(conf.env['PREFIX'],"lib","python"+pyver)
		if'PYTHONARCHDIR'in conf.env:
			pyarchdir=conf.env['PYTHONARCHDIR']
		elif'PYTHONARCHDIR'in conf.environ:
			pyarchdir=conf.environ['PYTHONARCHDIR']
		else:
			(pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0) or ''"])
			if not pyarchdir:
				pyarchdir=pydir
		if hasattr(conf,'define'):
			conf.define('PYTHONDIR',pydir)
			conf.define('PYTHONARCHDIR',pyarchdir)
		conf.env['PYTHONDIR']=pydir
		conf.env['PYTHONARCHDIR']=pyarchdir
	pyver_full='.'.join(map(str,pyver_tuple[:3]))
	if minver is None:
		conf.msg('Checking for python version',pyver_full)
	else:
		minver_str='.'.join(map(str,minver))
		conf.msg('Checking for python version',pyver_tuple,">= %s"%(minver_str,)and'GREEN'or'YELLOW')
	if not result:
		conf.fatal('The python version is too old, expecting %r'%(minver,))
Пример #7
0
def check_filesystem(conf):
    conf.start_msg('Checking filesystem support')
    try:
        conf.check_cxx(
         fragment='\n'.join([
          '#include <filesystem>',
          'int main() { std::tr2::sys::path path; }',
         ]),
         execute=False,
        )
        conf.define('STL_FILESYSTEM_ENABLED', 1)
        conf.end_msg('<filesystem>')
    except:
        conf.end_msg('<boost/filesystem.hpp>')
Пример #8
0
def check_tbb(conf):
        conf.env.LIB_TBB = ['tbb']
	if conf.options.tbb:
		conf.env.INCLUDES_TBB = [conf.options.tbb + '/include']
		conf.env.LIBPATH_TBB = [conf.options.tbb + '/lib']
	else:
		conf.env.INCLUDES_TBB = ['/usr/local/include',
                                           '/usr/include']
		conf.env.LIBPATH_TBB = ['/usr/local/lib/',
                                           '/usr/lib']

        try:
                res = conf.find_file('tbb/parallel_for.h', conf.env.INCLUDES_TBB)
                conf.define("USE_TBB", 1)
        except:
                print 'TBB not found'
Пример #9
0
def check_osx_security(conf, *k, **kw):
    if Utils.unversioned_sys_platform() == "darwin":
        try:
            conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION',
                           mandatory=True)
            conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES',
                           mandatory=True)
            conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY',
                           define_name='HAVE_SECURITY', use="OSX_COREFOUNDATION",
                           fragment=OSX_SECURITY_CODE, mandatory=True)

            conf.define('HAVE_OSX_SECURITY', 1)
            conf.env['HAVE_OSX_SECURITY'] = True
        except:
            Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, or Security framework is not functional.")
            Logs.warn("The frameworks are known to work only with Apple-specific compilers: llvm-gcc-4.2 or clang")
Пример #10
0
def configure (conf):
    
    # debugging option
    if conf.options.debug:
        conf.define ("DEBUG", 1)
        conf.define ("_DEBUG", 1)
        conf.env.append_unique ('CXXFLAGS', ['-g', '-ggdb', '-O0'])
        conf.env.append_unique ('CFLAGS', ['-g', '-ggdb', '-O0'])
    else:
        conf.define ("NDEBUG", 1)
        conf.env.append_unique ('CXXFLAGS', ['-Os'])
        conf.env.append_unique ('CFLAGS', ['-Os'])
    
    # output dir (build dir)
    outdir = conf.options.out
    if len (outdir) == 0:
        outdir = "build"
    
    # module path
    if not conf.env.JUCE_MODULE_PATH:
        conf.env.JUCE_MODULE_PATH = os.path.join (os.path.expanduser("~"), 'juce/modules')
    
    # define a library pattern suitable for plugins/modules
    # (e.g. remove the 'lib' from libplugin.XXX)
    pat = conf.env['cshlib_PATTERN']
    if not pat:
        pat = conf.env['cxxshlib_PATTERN']
    if pat.startswith('lib'):
        pat = pat[3:]
    conf.env['plugin_PATTERN'] = pat
    conf.env['plugin_EXT'] = pat[pat.rfind('.'):]
    
    # do platform stuff
    if is_linux():
        conf.define ('LINUX', 1)
    elif is_mac():
        conf.env.FRAMEWORK_ACCELERATE     = 'Accelerate'
        conf.env.FRAMEWORK_AUDIO_TOOLBOX  = 'AudioToolbox'
        conf.env.FRAMEWORK_AUDIO_UNIT     = 'AudioUnit'
        conf.env.FRAMEWORK_CORE_AUDIO     = 'CoreAudio'
        conf.env.FRAMEWORK_CORE_AUDIO_KIT = 'CoreAudioKit'
        conf.env.FRAMEWORK_CORE_MIDI      = 'CoreMIDI'
        conf.env.FRAMEWORK_COCOA          = 'Cocoa'
        conf.env.FRAMEWORK_CARBON         = 'Carbon'
        conf.env.FRAMEWORK_DISC_RECORDING = 'DiscRecording'
        conf.env.FRAMEWORK_IO_KIT         = 'IOKit'
        conf.env.FRAMEWORK_OPEN_GL        = 'OpenGL'
        conf.env.FRAMEWORK_QT_KIT         = 'QTKit'
        conf.env.FRAMEWORK_QuickTime      = 'QuickTime'
        conf.env.FRAMEWORK_QUARTZ_CORE    = 'QuartzCore'
        conf.env.FRAMEWORK_WEB_KIT        = 'WebKit'
    elif is_win32(): pass
Пример #11
0
def set_env(conf):
    conf.env.MSVC_LAZY_AUTODETECT = True
    conf.define('BOOSTTHREAD_USE_LIB', 1)
    conf.define('BOOSTTHREAD_VERSION', 4)
    conf.define('GTEST_LANG_CXX11', 1)
    for key, value in TARGETS[conf.env.TARGET].items():
        conf.env[key] = value
Пример #12
0
def check_python_headers(conf):
	env=conf.env
	if not env['CC_NAME']and not env['CXX_NAME']:
		conf.fatal('load a compiler first (gcc, g++, ..)')
	if not env['PYTHON_VERSION']:
		conf.check_python_version()
	pybin=conf.env.PYTHON
	if not pybin:
		conf.fatal('Could not find the python executable')
	v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
	try:
		lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v])
	except RuntimeError:
		conf.fatal("Python development headers not found (-v for details).")
	vals=['%s = %r'%(x,y)for(x,y)in zip(v,lst)]
	conf.to_log("Configuration returned from %r:\n%r\n"%(pybin,'\n'.join(vals)))
	dct=dict(zip(v,lst))
	x='MACOSX_DEPLOYMENT_TARGET'
	if dct[x]:
		conf.env[x]=conf.environ[x]=dct[x]
	if not env.pyext_PATTERN:
		if dct['SO']:
			env.pyext_PATTERN='%s'+dct['SO']
		else:
			env.pyext_PATTERN=(conf.env.cshlib_PATTERN or conf.env.cxxshlib_PATTERN).lstrip('lib')
	num='.'.join(env['PYTHON_VERSION'].split('.')[:2])
	conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',msg="python-config")
	all_flags=[['--cflags','--libs','--ldflags']]
	if sys.hexversion<0x2060000:
		all_flags=[[x]for x in all_flags[0]]
	xx=conf.env.CXX_NAME and'cxx'or'c'
	for flags in all_flags:
		conf.check_cfg(msg='Asking python-config for pyembed %r flags'%' '.join(flags),path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=flags)
	conf.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx))
	for flags in all_flags:
		conf.check_cfg(msg='Asking python-config for pyext %r flags'%' '.join(flags),path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=flags)
	conf.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions')
	conf.define('HAVE_PYTHON_H',1)
Пример #13
0
def configure(conf):
    conf.env.TARGET = platform.system().lower() + '_' + platform.machine().lower()
    conf.msg('Setting target to', conf.env.TARGET)

    conf.define('GTEST_LANG_CXX11', 1)
    conf.define('BOOSTTHREAD_USE_LIB', 1)
    conf.define('BOOSTTHREAD_VERSION', 4)
    for key, value in TARGETS[conf.env.TARGET].items():
        conf.env[key] = value

    conf.load('cpplint waf_unit_test compiler_cxx boost qt5')

    env = conf.env.derive()
    conf.set_variant('release', env)
    conf.check_libs()

    conf.set_variant('debug', env)
    conf.check_libs()

    Logs.info('---------------------------------------- :')
    conf.check_cpp14()
Пример #14
0
def check_python_headers(conf, features='pyembed pyext'):
	"""
	Check for headers and libraries necessary to extend or embed python by using the module *distutils*.
	On success the environment variables xxx_PYEXT and xxx_PYEMBED are added:

	* PYEXT: for compiling python extensions
	* PYEMBED: for embedding a python interpreter
	"""
	features = Utils.to_list(features)
	assert ('pyembed' in features) or ('pyext' in features), "check_python_headers features must include 'pyembed' and/or 'pyext'"
	env = conf.env
	if not env.CC_NAME and not env.CXX_NAME:
		conf.fatal('load a compiler first (gcc, g++, ..)')

	# bypass all the code below for cross-compilation
	if conf.python_cross_compile(features):
		return

	if not env.PYTHON_VERSION:
		conf.check_python_version()

	pybin = env.PYTHON
	if not pybin:
		conf.fatal('Could not find the python executable')

	# so we actually do all this for compatibility reasons and for obtaining pyext_PATTERN below
	v = 'prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
	try:
		lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
	except RuntimeError:
		conf.fatal("Python development headers not found (-v for details).")

	vals = ['%s = %r' % (x, y) for (x, y) in zip(v, lst)]
	conf.to_log("Configuration returned from %r:\n%s\n" % (pybin, '\n'.join(vals)))

	dct = dict(zip(v, lst))
	x = 'MACOSX_DEPLOYMENT_TARGET'
	if dct[x]:
		env[x] = conf.environ[x] = dct[x]
	env.pyext_PATTERN = '%s' + dct['SO'] # not a mistake


	# Try to get pythonX.Y-config
	num = '.'.join(env.PYTHON_VERSION.split('.')[:2])
	conf.find_program([''.join(pybin) + '-config', 'python%s-config' % num, 'python-config-%s' % num, 'python%sm-config' % num], var='PYTHON_CONFIG', msg="python-config", mandatory=False)

	if env.PYTHON_CONFIG:
		# python2.6-config requires 3 runs
		all_flags = [['--cflags', '--libs', '--ldflags']]
		if sys.hexversion < 0x2070000:
			all_flags = [[k] for k in all_flags[0]]

		xx = env.CXX_NAME and 'cxx' or 'c'

		if 'pyembed' in features:
			for flags in all_flags:
				conf.check_cfg(msg='Asking python-config for pyembed %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEMBED', args=flags)

			try:
				conf.test_pyembed(xx)
			except conf.errors.ConfigurationError:
				# python bug 7352
				if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
					env.append_unique('LIBPATH_PYEMBED', [dct['LIBDIR']])
					conf.test_pyembed(xx)
				else:
					raise

		if 'pyext' in features:
			for flags in all_flags:
				conf.check_cfg(msg='Asking python-config for pyext %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEXT', args=flags)

			try:
				conf.test_pyext(xx)
			except conf.errors.ConfigurationError:
				# python bug 7352
				if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
					env.append_unique('LIBPATH_PYEXT', [dct['LIBDIR']])
					conf.test_pyext(xx)
				else:
					raise

		conf.define('HAVE_PYTHON_H', 1)
		return

	# No python-config, do something else on windows systems
	all_flags = dct['LDFLAGS'] + ' ' + dct['CFLAGS']
	conf.parse_flags(all_flags, 'PYEMBED')

	all_flags = dct['LDFLAGS'] + ' ' + dct['LDSHARED'] + ' ' + dct['CFLAGS']
	conf.parse_flags(all_flags, 'PYEXT')

	result = None
	if not dct["LDVERSION"]:
		dct["LDVERSION"] = env.PYTHON_VERSION

	# further simplification will be complicated
	for name in ('python' + dct['LDVERSION'], 'python' + env.PYTHON_VERSION + 'm', 'python' + env.PYTHON_VERSION.replace('.', '')):

		# LIBPATH_PYEMBED is already set; see if it works.
		if not result and env.LIBPATH_PYEMBED:
			path = env.LIBPATH_PYEMBED
			conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n" % path)
			result = conf.check(lib=name, uselib='PYEMBED', libpath=path, mandatory=False, msg='Checking for library %s in LIBPATH_PYEMBED' % name)

		if not result and dct['LIBDIR']:
			path = [dct['LIBDIR']]
			conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n" % path)
			result = conf.check(lib=name, uselib='PYEMBED', libpath=path, mandatory=False, msg='Checking for library %s in LIBDIR' % name)

		if not result and dct['LIBPL']:
			path = [dct['LIBPL']]
			conf.to_log("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n")
			result = conf.check(lib=name, uselib='PYEMBED', libpath=path, mandatory=False, msg='Checking for library %s in python_LIBPL' % name)

		if not result:
			path = [os.path.join(dct['prefix'], "libs")]
			conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n")
			result = conf.check(lib=name, uselib='PYEMBED', libpath=path, mandatory=False, msg='Checking for library %s in $prefix/libs' % name)

		if result:
			break # do not forget to set LIBPATH_PYEMBED

	if result:
		env.LIBPATH_PYEMBED = path
		env.append_value('LIB_PYEMBED', [name])
	else:
		conf.to_log("\n\n### LIB NOT FOUND\n")

	# under certain conditions, python extensions must link to
	# python libraries, not just python embedding programs.
	if Utils.is_win32 or dct['Py_ENABLE_SHARED']:
		env.LIBPATH_PYEXT = env.LIBPATH_PYEMBED
		env.LIB_PYEXT = env.LIB_PYEMBED

	conf.to_log("Include path for Python extensions (found via distutils module): %r\n" % (dct['INCLUDEPY'],))
	env.INCLUDES_PYEXT = [dct['INCLUDEPY']]
	env.INCLUDES_PYEMBED = [dct['INCLUDEPY']]

	# Code using the Python API needs to be compiled with -fno-strict-aliasing
	if env.CC_NAME == 'gcc':
		env.append_value('CFLAGS_PYEMBED', ['-fno-strict-aliasing'])
		env.append_value('CFLAGS_PYEXT', ['-fno-strict-aliasing'])
	if env.CXX_NAME == 'gcc':
		env.append_value('CXXFLAGS_PYEMBED', ['-fno-strict-aliasing'])
		env.append_value('CXXFLAGS_PYEXT', ['-fno-strict-aliasing'])

	if env.CC_NAME == "msvc":
		from distutils.msvccompiler import MSVCCompiler
		dist_compiler = MSVCCompiler()
		dist_compiler.initialize()
		env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options)
		env.append_value('CXXFLAGS_PYEXT', dist_compiler.compile_options)
		env.append_value('LINKFLAGS_PYEXT', dist_compiler.ldflags_shared)

	# See if it compiles
	conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG, errmsg='Distutils not installed? Broken python installation? Get python-config now!')
Пример #15
0
def configure(conf):
    conf.load('compiler_c intltool')

    path, version = get_pkg_path_and_version("pidgin")
    conf.env.PIDGIN_PATH = path
    conf.env.PURPLE_PATH = join(path, "libpurple")
    conf.env.PURPLE_VERSION = version

    if conf.env.PURPLE_SSL:
        # Order matters: It seems like ssl-gnutls has to be loaded before
        # core-ssl to be found (see ssl.c:probe_ssl_plugins)
        conf.env.PURPLE_PLUGINS += ["ssl-" + conf.env.PURPLE_SSL, "ssl"]

        conf.env.append_value("LIB_PURPLE_BUILD", ["gnutls"])

    plugins = conf.env.PURPLE_PLUGINS

    conf.check_cfg(atleast_pkgconfig_version='0.1')
    conf.check_cfg(package='libxml-2.0', uselib_store='XML',
                   args=['--cflags', '--libs'])

    conf.env.append_value("DEFINES_PURPLE_BUILD", ["HAVE_CONFIG_H"])
    conf.env.append_value("INCLUDES_PURPLE_BUILD", ["libpurple_config",
                                                    conf.env.PURPLE_PATH])
    conf.env.append_value("LIB_PURPLE_BUILD", ["resolv"])

    # We are going to build a shared library
    conf.env.append_value("CFLAGS_PURPLE_BUILD", ["-fPIC"])

    headers = ["arpa/nameser_compat", "fcntl", "sys/time",
               "unistd", "locale", "libintl", "signal", "stdint", "regex"]

    for i in headers:
        conf.check_cc(header_name=i + ".h", mandatory=False,
                      auto_add_header_name=True)

    conf.define("PURPLE_PLUGINS", 1)
    conf.define("HAVE_GETIFADDRS", 1)
    conf.define("HAVE_INET_NTOP", 1)
    conf.define("HAVE_INET_ATON", 1)
    conf.define("HAVE_GETADDRINFO", 1)
    conf.define("HAVE_STRUCT_TM_TM_ZONE", 1)
    conf.define("HAVE_TM_GMTOFF", 1)
    conf.define("HAVE_TIMEZONE", 1)
    conf.define("HAVE_TIMGM", 1)
    conf.define("HAVE_STRFTIME_Z_FORMAT", 1)
    conf.define("HAVE_FILENO", 1)
    conf.define("HAVE_STRUCT_SOCKADDR_SA_LEN", 1)
    conf.define("VERSION", conf.env.PURPLE_VERSION)
    conf.define("DISPLAY_VERSION", conf.env.PURPLE_VERSION)
    conf.define("DATADIR", ".")
    conf.define("SYSCONFDIR", ".")
    conf.define("PACKAGE_NAME", "libpurple")
    conf.define("HAVE_SSL", 1)
    conf.define("HAVE_ICONV", 1)
    conf.define("SIZEOF_TIME_T", 4, quote=False)
    conf.define("HAVE_CONFIG_H", 1, quote=False)
    conf.define("HAVE_GNUTLS_PRIORITY_FUNCS", 1)
    conf.define("_GNU_SOURCE", 1, quote=False)

    conf.define("SSL_CERTIFICATES_DIR",
            join(conf.env.APP_PATH, "share", "ca-certs")
    )
    conf.define("LIBDIR", conf.env.PLUGIN_PATH)

    conf.define("ENABLE_NLS", 1, quote=False)
    conf.define("PACKAGE", "libpurple")
    conf.define("LOCALEDIR",
                join(conf.env.APP_PATH, "share", "locale")
    )

    conf.define("STATIC_PROTO_INIT", "void static_proto_init() {}", quote=False)
    conf.write_config_header('libpurple_config/config.h')

    conf.load('protocols', tooldir=conf.env.TOOLDIR)
Пример #16
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    pybin = conf.env['PYTHON']
    if not pybin:
        conf.fatal('could not find the python executable')
    cmd = pybin + [
        '-c', 'import sys\nfor x in sys.version_info: print(str(x))'
    ]
    Logs.debug('python: Running python command %r' % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines),
                                                                lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3],
                   int(lines[4]))
    result = (minver is None) or (pyver_tuple >= minver)
    if result:
        pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
        conf.env['PYTHON_VERSION'] = pyver
        if 'PYTHONDIR' in conf.environ:
            pydir = conf.environ['PYTHONDIR']
        else:
            if Utils.is_win32:
                (python_LIBDEST, pydir) = conf.get_python_variables([
                    "get_config_var('LIBDEST') or ''",
                    "get_python_lib(standard_lib=0, prefix=%r) or ''" %
                    conf.env['PREFIX']
                ])
            else:
                python_LIBDEST = None
                (pydir, ) = conf.get_python_variables([
                    "get_python_lib(standard_lib=0, prefix=%r) or ''" %
                    conf.env['PREFIX']
                ])
            if python_LIBDEST is None:
                if conf.env['LIBDIR']:
                    python_LIBDEST = os.path.join(conf.env['LIBDIR'],
                                                  "python" + pyver)
                else:
                    python_LIBDEST = os.path.join(conf.env['PREFIX'], "lib",
                                                  "python" + pyver)
        if 'PYTHONARCHDIR' in conf.environ:
            pyarchdir = conf.environ['PYTHONARCHDIR']
        else:
            (pyarchdir, ) = conf.get_python_variables([
                "get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''"
                % conf.env['PREFIX']
            ])
            if not pyarchdir:
                pyarchdir = pydir
        if hasattr(conf, 'define'):
            conf.define('PYTHONDIR', pydir)
            conf.define('PYTHONARCHDIR', pyarchdir)
        conf.env['PYTHONDIR'] = pydir
        conf.env['PYTHONARCHDIR'] = pyarchdir
    pyver_full = '.'.join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg('Checking for python version', pyver_full)
    else:
        minver_str = '.'.join(map(str, minver))
        conf.msg('Checking for python version', pyver_tuple,
                 ">= %s" % (minver_str, ) and 'GREEN' or 'YELLOW')
    if not result:
        conf.fatal('The python version is too old, expecting %r' % (minver, ))
Пример #17
0
def configure(conf):
    conf.load('compiler_c')

    path, version = get_path_and_version()
    conf.env.PURPLE_PATH = path
    conf.env.PURPLE_VERSION = version

    if conf.env.PURPLE_SSL:
        # Order matters: It seems like ssl-gnutls has to be loaded before
        # core-ssl to be found (see ssl.c:probe_ssl_plugins)
        conf.env.PURPLE_PLUGINS += ["ssl-" + conf.env.PURPLE_SSL, "ssl"]

        # TODO: conf.define("SSL_CERTIFICATE_DIR")
        conf.env.append_value("LIB_PURPLE_BUILD", ["gnutls"])

    plugins = conf.env.PURPLE_PLUGINS
    protocols = conf.env.PURPLE_PROTOCOLS

    if "jabber" in protocols:
        conf.env.PURPLE_SASL = True
        conf.load('sasl', tooldir='build_lib')
    else:
        conf.env.PURPLE_SASL = False

    conf.check_cfg(atleast_pkgconfig_version='0.1')
    conf.check_cfg(package='libxml-2.0', uselib_store='XML',
                   args=['--cflags', '--libs'])

    conf.env.append_value("DEFINES_PURPLE_BUILD", ["HAVE_CONFIG_H"])
    conf.env.append_value("INCLUDES_PURPLE_BUILD", ["libpurple_config", path])
    conf.env.append_value("LIB_PURPLE_BUILD", ["resolv"])

    # We are going to build a shared library
    conf.env.append_value("CFLAGS_PURPLE_BUILD", ["-fPIC"])

    headers = ["arpa/nameser_compat", "fcntl", "sys/time",
               "unistd", "locale", "signal", "stdint", "regex"]

    for i in headers:
        conf.check_cc(header_name=i + ".h", mandatory=False,
                      auto_add_header_name=True)

    conf.define("PURPLE_STATIC_PRPL", 1)
    conf.define("PURPLE_PLUGINS", 1)
    conf.define("HAVE_GETIFADDRS", 1)
    conf.define("HAVE_INET_NTOP", 1)
    conf.define("HAVE_INET_ATON", 1)
    conf.define("HAVE_GETADDRINFO", 1)
    conf.define("HAVE_STRUCT_TM_TM_ZONE", 1)
    conf.define("HAVE_TM_GMTOFF", 1)
    conf.define("HAVE_TIMEZONE", 1)
    conf.define("HAVE_TIMGM", 1)
    conf.define("HAVE_STRFTIME_Z_FORMAT", 1)
    conf.define("HAVE_FILENO", 1)
    conf.define("HAVE_STRUCT_SOCKADDR_SA_LEN", 1)
    conf.define("VERSION", conf.env.PURPLE_VERSION)
    conf.define("DISPLAY_VERSION", conf.env.PURPLE_VERSION)
    conf.define("DATADIR", ".")
    conf.define("SYSCONFDIR", ".")
    conf.define("PACKAGE_NAME", "libpurple")
    conf.define("HAVE_SSL", 1)
    conf.define("HAVE_ICONV", 1)
    conf.define("LIBDIR", ".")
    conf.define("SIZEOF_TIME_T", 4, quote=False)
    conf.define("HAVE_CONFIG_H", 1, quote=False)
    conf.define("HAVE_CYRUS_SASL", 1, quote=False)
    conf.define("HAVE_GNUTLS_PRIORITY_FUNCS", 1)
    conf.define("_GNU_SOURCE", 1, quote=False)

    proto_extern = "\\\n".join(
                        "extern gboolean purple_init_%s_plugin();" %
                            name.replace('-', '_')
                        for name in chain(plugins, protocols)
                        )

    proto_func = "\\\n".join(
                        "   purple_init_%s_plugin();" % name.replace('-', '_')
                        for name in chain(plugins, protocols)
                        )

    proto_init = """%s\\
void static_proto_init()\\
{\\
%s\\
}""" % (proto_extern, proto_func)

    conf.define("STATIC_PROTO_INIT", proto_init, quote=False)

    conf.write_config_header('libpurple_config/config.h')
Пример #18
0
def check_python_headers(conf, features='pyembed pyext'):
    features = Utils.to_list(features)
    assert ('pyembed' in features) or (
        'pyext' in features
    ), "check_python_headers features must include 'pyembed' and/or 'pyext'"
    env = conf.env
    if not env.CC_NAME and not env.CXX_NAME:
        conf.fatal('load a compiler first (gcc, g++, ..)')
    if conf.python_cross_compile(features):
        return
    if not env.PYTHON_VERSION:
        conf.check_python_version()
    pybin = env.PYTHON
    if not pybin:
        conf.fatal('Could not find the python executable')
    v = 'prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split(
    )
    try:
        lst = conf.get_python_variables(
            ["get_config_var('%s') or ''" % x for x in v])
    except RuntimeError:
        conf.fatal("Python development headers not found (-v for details).")
    vals = ['%s = %r' % (x, y) for (x, y) in zip(v, lst)]
    conf.to_log("Configuration returned from %r:\n%s\n" %
                (pybin, '\n'.join(vals)))
    dct = dict(zip(v, lst))
    x = 'MACOSX_DEPLOYMENT_TARGET'
    if dct[x]:
        env[x] = conf.environ[x] = dct[x]
    env.pyext_PATTERN = '%s' + dct['SO']
    num = '.'.join(env.PYTHON_VERSION.split('.')[:2])
    conf.find_program([
        ''.join(pybin) + '-config',
        'python%s-config' % num,
        'python-config-%s' % num,
        'python%sm-config' % num
    ],
                      var='PYTHON_CONFIG',
                      msg="python-config",
                      mandatory=False)
    if env.PYTHON_CONFIG:
        all_flags = [['--cflags', '--libs', '--ldflags']]
        if sys.hexversion < 0x2070000:
            all_flags = [[k] for k in all_flags[0]]
        xx = env.CXX_NAME and 'cxx' or 'c'
        if 'pyembed' in features:
            for flags in all_flags:
                conf.check_cfg(
                    msg='Asking python-config for pyembed %r flags' %
                    ' '.join(flags),
                    path=env.PYTHON_CONFIG,
                    package='',
                    uselib_store='PYEMBED',
                    args=flags)
            try:
                conf.test_pyembed(xx)
            except conf.errors.ConfigurationError:
                if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
                    env.append_unique('LIBPATH_PYEMBED', [dct['LIBDIR']])
                    conf.test_pyembed(xx)
                else:
                    raise
        if 'pyext' in features:
            for flags in all_flags:
                conf.check_cfg(msg='Asking python-config for pyext %r flags' %
                               ' '.join(flags),
                               path=env.PYTHON_CONFIG,
                               package='',
                               uselib_store='PYEXT',
                               args=flags)
            try:
                conf.test_pyext(xx)
            except conf.errors.ConfigurationError:
                if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
                    env.append_unique('LIBPATH_PYEXT', [dct['LIBDIR']])
                    conf.test_pyext(xx)
                else:
                    raise
        conf.define('HAVE_PYTHON_H', 1)
        return
    all_flags = dct['LDFLAGS'] + ' ' + dct['CFLAGS']
    conf.parse_flags(all_flags, 'PYEMBED')
    all_flags = dct['LDFLAGS'] + ' ' + dct['LDSHARED'] + ' ' + dct['CFLAGS']
    conf.parse_flags(all_flags, 'PYEXT')
    result = None
    if not dct["LDVERSION"]:
        dct["LDVERSION"] = env.PYTHON_VERSION
    for name in ('python' + dct['LDVERSION'],
                 'python' + env.PYTHON_VERSION + 'm',
                 'python' + env.PYTHON_VERSION.replace('.', '')):
        if not result and env.LIBPATH_PYEMBED:
            path = env.LIBPATH_PYEMBED
            conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n" % path)
            result = conf.check(
                lib=name,
                uselib='PYEMBED',
                libpath=path,
                mandatory=False,
                msg='Checking for library %s in LIBPATH_PYEMBED' % name)
        if not result and dct['LIBDIR']:
            path = [dct['LIBDIR']]
            conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n" % path)
            result = conf.check(lib=name,
                                uselib='PYEMBED',
                                libpath=path,
                                mandatory=False,
                                msg='Checking for library %s in LIBDIR' % name)
        if not result and dct['LIBPL']:
            path = [dct['LIBPL']]
            conf.to_log(
                "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n"
            )
            result = conf.check(lib=name,
                                uselib='PYEMBED',
                                libpath=path,
                                mandatory=False,
                                msg='Checking for library %s in python_LIBPL' %
                                name)
        if not result:
            path = [os.path.join(dct['prefix'], "libs")]
            conf.to_log(
                "\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n"
            )
            result = conf.check(lib=name,
                                uselib='PYEMBED',
                                libpath=path,
                                mandatory=False,
                                msg='Checking for library %s in $prefix/libs' %
                                name)
        if result:
            break
    if result:
        env.LIBPATH_PYEMBED = path
        env.append_value('LIB_PYEMBED', [name])
    else:
        conf.to_log("\n\n### LIB NOT FOUND\n")
    if Utils.is_win32 or dct['Py_ENABLE_SHARED']:
        env.LIBPATH_PYEXT = env.LIBPATH_PYEMBED
        env.LIB_PYEXT = env.LIB_PYEMBED
    conf.to_log(
        "Include path for Python extensions (found via distutils module): %r\n"
        % (dct['INCLUDEPY'], ))
    env.INCLUDES_PYEXT = [dct['INCLUDEPY']]
    env.INCLUDES_PYEMBED = [dct['INCLUDEPY']]
    if env.CC_NAME == 'gcc':
        env.append_value('CFLAGS_PYEMBED', ['-fno-strict-aliasing'])
        env.append_value('CFLAGS_PYEXT', ['-fno-strict-aliasing'])
    if env.CXX_NAME == 'gcc':
        env.append_value('CXXFLAGS_PYEMBED', ['-fno-strict-aliasing'])
        env.append_value('CXXFLAGS_PYEXT', ['-fno-strict-aliasing'])
    if env.CC_NAME == "msvc":
        from distutils.msvccompiler import MSVCCompiler
        dist_compiler = MSVCCompiler()
        dist_compiler.initialize()
        env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options)
        env.append_value('CXXFLAGS_PYEXT', dist_compiler.compile_options)
        env.append_value('LINKFLAGS_PYEXT', dist_compiler.ldflags_shared)
    conf.check(
        header_name='Python.h',
        define_name='HAVE_PYTHON_H',
        uselib='PYEMBED',
        fragment=FRAG,
        errmsg=
        'Distutils not installed? Broken python installation? Get python-config now!'
    )
Пример #19
0
def check_python_version(conf, minver=None):
    """
	Check if the python interpreter is found matching a given minimum version.
	minver should be a tuple, eg. to check for python >= 2.4.2 pass (2,4,2) as minver.

	If successful, PYTHON_VERSION is defined as 'MAJOR.MINOR'
	(eg. '2.4') of the actual python version found, and PYTHONDIR is
	defined, pointing to the site-packages directory appropriate for
	this python version, where modules/packages/extensions should be
	installed.

	:param minver: minimum version
	:type minver: tuple of int
	"""
    assert minver is None or isinstance(minver, tuple)
    python = conf.env["PYTHON"]
    if not python:
        conf.fatal("could not find the python executable")

        # Get python version string
    cmd = [python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"]
    debug("python: Running python command %r" % cmd)
    lines = conf.cmd_and_log(cmd).split()
    assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
    pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))

    # compare python version with the minimum required
    result = (minver is None) or (pyver_tuple >= minver)

    if result:
        # define useful environment variables
        pyver = ".".join([str(x) for x in pyver_tuple[:2]])
        conf.env["PYTHON_VERSION"] = pyver

        if "PYTHONDIR" in conf.environ:
            pydir = conf.environ["PYTHONDIR"]
        else:
            if sys.platform == "win32":
                (python_LIBDEST, pydir) = conf.get_python_variables(
                    python,
                    ["get_config_var('LIBDEST')", "get_python_lib(standard_lib=0, prefix=%r)" % conf.env["PREFIX"]],
                    ["from distutils.sysconfig import get_config_var, get_python_lib"],
                )
            else:
                python_LIBDEST = None
                (pydir,) = conf.get_python_variables(
                    python,
                    ["get_python_lib(standard_lib=0, prefix=%r)" % conf.env["PREFIX"]],
                    ["from distutils.sysconfig import get_config_var, get_python_lib"],
                )
            if python_LIBDEST is None:
                if conf.env["LIBDIR"]:
                    python_LIBDEST = os.path.join(conf.env["LIBDIR"], "python" + pyver)
                else:
                    python_LIBDEST = os.path.join(conf.env["PREFIX"], "lib", "python" + pyver)

        if hasattr(conf, "define"):  # conf.define is added by the C tool, so may not exist
            conf.define("PYTHONDIR", pydir)
        conf.env["PYTHONDIR"] = pydir

        # Feedback
    pyver_full = ".".join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.msg("Checking for python version", pyver_full)
    else:
        minver_str = ".".join(map(str, minver))
        conf.msg("Checking for python version", pyver_tuple, ">= %s" % (minver_str,) and "GREEN" or "YELLOW")

    if not result:
        conf.fatal("The python version is too old, expecting %r" % (minver,))
Пример #20
0
def configure(conf):
    # debugging option
    if conf.options.debug:
        conf.define("DEBUG", 1)
        conf.define("_DEBUG", 1)
        conf.env.append_unique('CXXFLAGS', ['-g', '-ggdb', '-O0'])
        conf.env.append_unique('CFLAGS', ['-g', '-ggdb', '-O0'])
    else:
        conf.define("NDEBUG", 1)
        conf.env.append_unique('CXXFLAGS', ['-Os'])
        conf.env.append_unique('CFLAGS', ['-Os'])

    # output dir (build dir)
    outdir = conf.options.out
    if len(outdir) == 0:
        outdir = "build"

    # module path
    if not conf.env.JUCE_MODULE_PATH:
        conf.env.JUCE_MODULE_PATH = os.path.join(os.path.expanduser("~"),
                                                 'SDKs/JUCE/modules')

    # define a library pattern suitable for plugins/modules
    # (e.g. remove the 'lib' from libplugin.so)
    pat = conf.env.cshlib_PATTERN
    if not pat:
        pat = conf.env.cxxshlib_PATTERN
    if pat.startswith('lib'):
        pat = pat[3:]
    conf.env.plugin_PATTERN = pat
    conf.env.plugin_EXT = pat[pat.rfind('.'):]

    # Platform
    if is_linux() and not 'mingw32' in conf.env.CXX[0]:
        conf.define('LINUX', 1)

    elif is_mac():
        conf.env.FRAMEWORK_ACCELERATE = 'Accelerate'
        conf.env.FRAMEWORK_AUDIO_TOOLBOX = 'AudioToolbox'
        conf.env.FRAMEWORK_CORE_AUDIO = 'CoreAudio'
        conf.env.FRAMEWORK_CORE_AUDIO_KIT = 'CoreAudioKit'
        conf.env.FRAMEWORK_CORE_MEDIA = 'CoreMedia'
        conf.env.FRAMEWORK_CORE_MIDI = 'CoreMIDI'
        conf.env.FRAMEWORK_COCOA = 'Cocoa'
        conf.env.FRAMEWORK_CARBON = 'Carbon'
        conf.env.FRAMEWORK_DISC_RECORDING = 'DiscRecording'
        conf.env.FRAMEWORK_IO_KIT = 'IOKit'
        conf.env.FRAMEWORK_OPEN_GL = 'OpenGL'
        conf.env.FRAMEWORK_QT_KIT = 'QTKit'
        conf.env.FRAMEWORK_QuickTime = 'QuickTime'
        conf.env.FRAMEWORK_QUARTZ_CORE = 'QuartzCore'
        conf.env.FRAMEWORK_WEB_KIT = 'WebKit'
        conf.env.FRAMEWORK_AV_KIT = 'AVKit'
        conf.env.FRAMEWORK_AV_FOUNDATION = 'AVFoundation'

        # ARCH
        if len(conf.options.mac_arch) > 0:
            conf.env.ARCH = conf.options.mac_arch.split(',')

        # Min OSX Version
        if (len(conf.options.mac_version_min) > 0):
            conf.env.append_unique(
                'CXXFLAGS',
                ['-mmacosx-version-min=%s' % conf.options.mac_version_min])

    elif is_win32():
        pass
Пример #21
0
def check_python_headers(conf):
    env = conf.env
    if not env["CC_NAME"] and not env["CXX_NAME"]:
        conf.fatal("load a compiler first (gcc, g++, ..)")
    if not env["PYTHON_VERSION"]:
        conf.check_python_version()
    pybin = env.PYTHON
    if not pybin:
        conf.fatal("Could not find the python executable")
    v = "prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION".split()
    try:
        lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
    except RuntimeError:
        conf.fatal("Python development headers not found (-v for details).")
    vals = ["%s = %r" % (x, y) for (x, y) in zip(v, lst)]
    conf.to_log("Configuration returned from %r:\n%r\n" % (pybin, "\n".join(vals)))
    dct = dict(zip(v, lst))
    x = "MACOSX_DEPLOYMENT_TARGET"
    if dct[x]:
        env[x] = conf.environ[x] = dct[x]
    env["pyext_PATTERN"] = "%s" + dct["SO"]
    num = ".".join(env["PYTHON_VERSION"].split(".")[:2])
    conf.find_program(
        ["".join(pybin) + "-config", "python%s-config" % num, "python-config-%s" % num, "python%sm-config" % num],
        var="PYTHON_CONFIG",
        msg="python-config",
        mandatory=False,
    )
    if env.PYTHON_CONFIG:
        all_flags = [["--cflags", "--libs", "--ldflags"]]
        if sys.hexversion < 0x2060000:
            all_flags = [[k] for k in all_flags[0]]
        xx = env.CXX_NAME and "cxx" or "c"
        for flags in all_flags:
            conf.check_cfg(
                msg="Asking python-config for pyembed %r flags" % " ".join(flags),
                path=env.PYTHON_CONFIG,
                package="",
                uselib_store="PYEMBED",
                args=flags,
            )
        conf.check(
            header_name="Python.h",
            define_name="HAVE_PYEMBED",
            msg="Getting pyembed flags from python-config",
            fragment=FRAG,
            errmsg="Could not build a python embedded interpreter",
            features="%s %sprogram pyembed" % (xx, xx),
        )
        for flags in all_flags:
            conf.check_cfg(
                msg="Asking python-config for pyext %r flags" % " ".join(flags),
                path=env.PYTHON_CONFIG,
                package="",
                uselib_store="PYEXT",
                args=flags,
            )
        conf.check(
            header_name="Python.h",
            define_name="HAVE_PYEXT",
            msg="Getting pyext flags from python-config",
            features="%s %sshlib pyext" % (xx, xx),
            fragment=FRAG,
            errmsg="Could not build python extensions",
        )
        conf.define("HAVE_PYTHON_H", 1)
        return
    all_flags = dct["LDFLAGS"] + " " + dct["CFLAGS"]
    conf.parse_flags(all_flags, "PYEMBED")
    all_flags = dct["LDFLAGS"] + " " + dct["LDSHARED"] + " " + dct["CFLAGS"]
    conf.parse_flags(all_flags, "PYEXT")
    result = None
    if not dct["LDVERSION"]:
        dct["LDVERSION"] = env["PYTHON_VERSION"]
    for name in (
        "python" + dct["LDVERSION"],
        "python" + env["PYTHON_VERSION"] + "m",
        "python" + env["PYTHON_VERSION"].replace(".", ""),
    ):
        if not result and env["LIBPATH_PYEMBED"]:
            path = env["LIBPATH_PYEMBED"]
            conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n" % path)
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in LIBPATH_PYEMBED" % name,
            )
        if not result and dct["LIBDIR"]:
            path = [dct["LIBDIR"]]
            conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n" % path)
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in LIBDIR" % name,
            )
        if not result and dct["LIBPL"]:
            path = [dct["LIBPL"]]
            conf.to_log(
                "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n"
            )
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in python_LIBPL" % name,
            )
        if not result:
            path = [os.path.join(dct["prefix"], "libs")]
            conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n")
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in $prefix/libs" % name,
            )
        if result:
            break
    if result:
        env["LIBPATH_PYEMBED"] = path
        env.append_value("LIB_PYEMBED", [name])
    else:
        conf.to_log("\n\n### LIB NOT FOUND\n")
    if Utils.is_win32 or dct["Py_ENABLE_SHARED"]:
        env["LIBPATH_PYEXT"] = env["LIBPATH_PYEMBED"]
        env["LIB_PYEXT"] = env["LIB_PYEMBED"]
    conf.to_log("Include path for Python extensions (found via distutils module): %r\n" % (dct["INCLUDEPY"],))
    env["INCLUDES_PYEXT"] = [dct["INCLUDEPY"]]
    env["INCLUDES_PYEMBED"] = [dct["INCLUDEPY"]]
    if env["CC_NAME"] == "gcc":
        env.append_value("CFLAGS_PYEMBED", ["-fno-strict-aliasing"])
        env.append_value("CFLAGS_PYEXT", ["-fno-strict-aliasing"])
    if env["CXX_NAME"] == "gcc":
        env.append_value("CXXFLAGS_PYEMBED", ["-fno-strict-aliasing"])
        env.append_value("CXXFLAGS_PYEXT", ["-fno-strict-aliasing"])
    if env.CC_NAME == "msvc":
        from distutils.msvccompiler import MSVCCompiler

        dist_compiler = MSVCCompiler()
        dist_compiler.initialize()
        env.append_value("CFLAGS_PYEXT", dist_compiler.compile_options)
        env.append_value("CXXFLAGS_PYEXT", dist_compiler.compile_options)
        env.append_value("LINKFLAGS_PYEXT", dist_compiler.ldflags_shared)
    conf.check(
        header_name="Python.h",
        define_name="HAVE_PYTHON_H",
        uselib="PYEMBED",
        fragment=FRAG,
        errmsg="Distutils not installed? Broken python installation? Get python-config now!",
    )
Пример #22
0
def setting_define (conf, key, val, key_format = "_IBEX_%s_", **kwargs):
	conf.setenv ("setting")
	conf.define (key_format % key, val, **kwargs)
	conf.setenv("")
Пример #23
0
def check_python_headers(conf):
	env=conf.env
	if not env['CC_NAME']and not env['CXX_NAME']:
		conf.fatal('load a compiler first (gcc, g++, ..)')
	if not env['PYTHON_VERSION']:
		conf.check_python_version()
	pybin=env.PYTHON
	if not pybin:
		conf.fatal('Could not find the python executable')
	v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
	try:
		lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v])
	except RuntimeError:
		conf.fatal("Python development headers not found (-v for details).")
	vals=['%s = %r'%(x,y)for(x,y)in zip(v,lst)]
	conf.to_log("Configuration returned from %r:\n%r\n"%(pybin,'\n'.join(vals)))
	dct=dict(zip(v,lst))
	x='MACOSX_DEPLOYMENT_TARGET'
	if dct[x]:
		env[x]=conf.environ[x]=dct[x]
	env['pyext_PATTERN']='%s'+dct['SO']
	num='.'.join(env['PYTHON_VERSION'].split('.')[:2])
	conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',msg="python-config",mandatory=False)
	if env.PYTHON_CONFIG:
		all_flags=[['--cflags','--libs','--ldflags']]
		if sys.hexversion<0x2060000:
			all_flags=[[k]for k in all_flags[0]]
		xx=env.CXX_NAME and'cxx'or'c'
		for flags in all_flags:
			conf.check_cfg(msg='Asking python-config for pyembed %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=flags)
		conf.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx))
		for flags in all_flags:
			conf.check_cfg(msg='Asking python-config for pyext %r flags'%' '.join(flags),path=env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=flags)
		conf.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions')
		conf.define('HAVE_PYTHON_H',1)
		return
	all_flags=dct['LDFLAGS']+' '+dct['CFLAGS']
	conf.parse_flags(all_flags,'PYEMBED')
	all_flags=dct['LDFLAGS']+' '+dct['LDSHARED']+' '+dct['CFLAGS']
	conf.parse_flags(all_flags,'PYEXT')
	result=None
	if not dct["LDVERSION"]:
		dct["LDVERSION"]=env['PYTHON_VERSION']
	for name in('python'+dct['LDVERSION'],'python'+env['PYTHON_VERSION']+'m','python'+env['PYTHON_VERSION'].replace('.','')):
		if not result and env['LIBPATH_PYEMBED']:
			path=env['LIBPATH_PYEMBED']
			conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n"%path)
			result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in LIBPATH_PYEMBED'%name)
		if not result and dct['LIBDIR']:
			path=[dct['LIBDIR']]
			conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n"%path)
			result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in LIBDIR'%name)
		if not result and dct['LIBPL']:
			path=[dct['LIBPL']]
			conf.to_log("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n")
			result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in python_LIBPL'%name)
		if not result:
			path=[os.path.join(dct['prefix'],"libs")]
			conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n")
			result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in $prefix/libs'%name)
		if result:
			break
	if result:
		env['LIBPATH_PYEMBED']=path
		env.append_value('LIB_PYEMBED',[name])
	else:
		conf.to_log("\n\n### LIB NOT FOUND\n")
	if Utils.is_win32 or dct['Py_ENABLE_SHARED']:
		env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED']
		env['LIB_PYEXT']=env['LIB_PYEMBED']
	conf.to_log("Include path for Python extensions (found via distutils module): %r\n"%(dct['INCLUDEPY'],))
	env['INCLUDES_PYEXT']=[dct['INCLUDEPY']]
	env['INCLUDES_PYEMBED']=[dct['INCLUDEPY']]
	if env['CC_NAME']=='gcc':
		env.append_value('CFLAGS_PYEMBED',['-fno-strict-aliasing'])
		env.append_value('CFLAGS_PYEXT',['-fno-strict-aliasing'])
	if env['CXX_NAME']=='gcc':
		env.append_value('CXXFLAGS_PYEMBED',['-fno-strict-aliasing'])
		env.append_value('CXXFLAGS_PYEXT',['-fno-strict-aliasing'])
	if env.CC_NAME=="msvc":
		from distutils.msvccompiler import MSVCCompiler
		dist_compiler=MSVCCompiler()
		dist_compiler.initialize()
		env.append_value('CFLAGS_PYEXT',dist_compiler.compile_options)
		env.append_value('CXXFLAGS_PYEXT',dist_compiler.compile_options)
		env.append_value('LINKFLAGS_PYEXT',dist_compiler.ldflags_shared)
	conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG,errmsg='Distutils not installed? Broken python installation? Get python-config now!')
Пример #24
0
def check_python_headers(conf, features="pyembed pyext"):
    """
	Check for headers and libraries necessary to extend or embed python by using the module *distutils*.
	On success the environment variables xxx_PYEXT and xxx_PYEMBED are added:

	* PYEXT: for compiling python extensions
	* PYEMBED: for embedding a python interpreter
	"""
    features = Utils.to_list(features)
    assert ("pyembed" in features) or (
        "pyext" in features
    ), "check_python_headers features must include 'pyembed' and/or 'pyext'"
    env = conf.env
    if not env["CC_NAME"] and not env["CXX_NAME"]:
        conf.fatal("load a compiler first (gcc, g++, ..)")

        # bypass all the code below for cross-compilation
    if conf.python_cross_compile(features):
        return

    if not env["PYTHON_VERSION"]:
        conf.check_python_version()

    pybin = env.PYTHON
    if not pybin:
        conf.fatal("Could not find the python executable")

        # so we actually do all this for compatibility reasons and for obtaining pyext_PATTERN below
    v = "prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION".split()
    try:
        lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
    except RuntimeError:
        conf.fatal("Python development headers not found (-v for details).")

    vals = ["%s = %r" % (x, y) for (x, y) in zip(v, lst)]
    conf.to_log("Configuration returned from %r:\n%s\n" % (pybin, "\n".join(vals)))

    dct = dict(zip(v, lst))
    x = "MACOSX_DEPLOYMENT_TARGET"
    if dct[x]:
        env[x] = conf.environ[x] = dct[x]
    env["pyext_PATTERN"] = "%s" + dct["SO"]  # not a mistake

    # Try to get pythonX.Y-config
    num = ".".join(env["PYTHON_VERSION"].split(".")[:2])
    conf.find_program(
        ["".join(pybin) + "-config", "python%s-config" % num, "python-config-%s" % num, "python%sm-config" % num],
        var="PYTHON_CONFIG",
        msg="python-config",
        mandatory=False,
    )

    if env.PYTHON_CONFIG:
        # python2.6-config requires 3 runs
        all_flags = [["--cflags", "--libs", "--ldflags"]]
        if sys.hexversion < 0x2070000:
            all_flags = [[k] for k in all_flags[0]]

        xx = env.CXX_NAME and "cxx" or "c"

        if "pyembed" in features:
            for flags in all_flags:
                conf.check_cfg(
                    msg="Asking python-config for pyembed %r flags" % " ".join(flags),
                    path=env.PYTHON_CONFIG,
                    package="",
                    uselib_store="PYEMBED",
                    args=flags,
                )

            conf.check(
                header_name="Python.h",
                define_name="HAVE_PYEMBED",
                msg="Getting pyembed flags from python-config",
                fragment=FRAG,
                errmsg="Could not build a python embedded interpreter",
                features="%s %sprogram pyembed" % (xx, xx),
            )

        if "pyext" in features:
            for flags in all_flags:
                conf.check_cfg(
                    msg="Asking python-config for pyext %r flags" % " ".join(flags),
                    path=env.PYTHON_CONFIG,
                    package="",
                    uselib_store="PYEXT",
                    args=flags,
                )

            conf.check(
                header_name="Python.h",
                define_name="HAVE_PYEXT",
                msg="Getting pyext flags from python-config",
                features="%s %sshlib pyext" % (xx, xx),
                fragment=FRAG,
                errmsg="Could not build python extensions",
            )

        conf.define("HAVE_PYTHON_H", 1)
        return

        # No python-config, do something else on windows systems
    all_flags = dct["LDFLAGS"] + " " + dct["CFLAGS"]
    conf.parse_flags(all_flags, "PYEMBED")

    all_flags = dct["LDFLAGS"] + " " + dct["LDSHARED"] + " " + dct["CFLAGS"]
    conf.parse_flags(all_flags, "PYEXT")

    result = None
    if not dct["LDVERSION"]:
        dct["LDVERSION"] = env["PYTHON_VERSION"]

        # further simplification will be complicated
    for name in (
        "python" + dct["LDVERSION"],
        "python" + env["PYTHON_VERSION"] + "m",
        "python" + env["PYTHON_VERSION"].replace(".", ""),
    ):

        # LIBPATH_PYEMBED is already set; see if it works.
        if not result and env["LIBPATH_PYEMBED"]:
            path = env["LIBPATH_PYEMBED"]
            conf.to_log("\n\n# Trying default LIBPATH_PYEMBED: %r\n" % path)
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in LIBPATH_PYEMBED" % name,
            )

        if not result and dct["LIBDIR"]:
            path = [dct["LIBDIR"]]
            conf.to_log("\n\n# try again with -L$python_LIBDIR: %r\n" % path)
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in LIBDIR" % name,
            )

        if not result and dct["LIBPL"]:
            path = [dct["LIBPL"]]
            conf.to_log(
                "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n"
            )
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in python_LIBPL" % name,
            )

        if not result:
            path = [os.path.join(dct["prefix"], "libs")]
            conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n")
            result = conf.check(
                lib=name,
                uselib="PYEMBED",
                libpath=path,
                mandatory=False,
                msg="Checking for library %s in $prefix/libs" % name,
            )

        if result:
            break  # do not forget to set LIBPATH_PYEMBED

    if result:
        env["LIBPATH_PYEMBED"] = path
        env.append_value("LIB_PYEMBED", [name])
    else:
        conf.to_log("\n\n### LIB NOT FOUND\n")

        # under certain conditions, python extensions must link to
        # python libraries, not just python embedding programs.
    if Utils.is_win32 or dct["Py_ENABLE_SHARED"]:
        env["LIBPATH_PYEXT"] = env["LIBPATH_PYEMBED"]
        env["LIB_PYEXT"] = env["LIB_PYEMBED"]

    conf.to_log("Include path for Python extensions (found via distutils module): %r\n" % (dct["INCLUDEPY"],))
    env["INCLUDES_PYEXT"] = [dct["INCLUDEPY"]]
    env["INCLUDES_PYEMBED"] = [dct["INCLUDEPY"]]

    # Code using the Python API needs to be compiled with -fno-strict-aliasing
    if env["CC_NAME"] == "gcc":
        env.append_value("CFLAGS_PYEMBED", ["-fno-strict-aliasing"])
        env.append_value("CFLAGS_PYEXT", ["-fno-strict-aliasing"])
    if env["CXX_NAME"] == "gcc":
        env.append_value("CXXFLAGS_PYEMBED", ["-fno-strict-aliasing"])
        env.append_value("CXXFLAGS_PYEXT", ["-fno-strict-aliasing"])

    if env.CC_NAME == "msvc":
        from distutils.msvccompiler import MSVCCompiler

        dist_compiler = MSVCCompiler()
        dist_compiler.initialize()
        env.append_value("CFLAGS_PYEXT", dist_compiler.compile_options)
        env.append_value("CXXFLAGS_PYEXT", dist_compiler.compile_options)
        env.append_value("LINKFLAGS_PYEXT", dist_compiler.ldflags_shared)

        # See if it compiles
    conf.check(
        header_name="Python.h",
        define_name="HAVE_PYTHON_H",
        uselib="PYEMBED",
        fragment=FRAG,
        errmsg="Distutils not installed? Broken python installation? Get python-config now!",
    )
Пример #25
0
def check_python_version(conf, minver=None):
	"""
	Check if the python interpreter is found matching a given minimum version.
	minver should be a tuple, eg. to check for python >= 2.4.2 pass (2,4,2) as minver.

	If successful, PYTHON_VERSION is defined as 'MAJOR.MINOR'
	(eg. '2.4') of the actual python version found, and PYTHONDIR is
	defined, pointing to the site-packages directory appropriate for
	this python version, where modules/packages/extensions should be
	installed.

	:param minver: minimum version
	:type minver: tuple of int
	"""
	assert minver is None or isinstance(minver, tuple)
	pybin = conf.env['PYTHON']
	if not pybin:
		conf.fatal('could not find the python executable')

	# Get python version string
	cmd = pybin + ['-c', 'import sys\nfor x in sys.version_info: print(str(x))']
	Logs.debug('python: Running python command %r' % cmd)
	lines = conf.cmd_and_log(cmd).split()
	assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
	pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))

	# compare python version with the minimum required
	result = (minver is None) or (pyver_tuple >= minver)

	if result:
		# define useful environment variables
		pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
		conf.env['PYTHON_VERSION'] = pyver

		if 'PYTHONDIR' in conf.environ:
			pydir = conf.environ['PYTHONDIR']
		else:
			if Utils.is_win32:
				(python_LIBDEST, pydir) = conf.get_python_variables(
					  ["get_config_var('LIBDEST') or ''",
					   "get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			else:
				python_LIBDEST = None
				(pydir,) = conf.get_python_variables( ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			if python_LIBDEST is None:
				if conf.env['LIBDIR']:
					python_LIBDEST = os.path.join(conf.env['LIBDIR'], "python" + pyver)
				else:
					python_LIBDEST = os.path.join(conf.env['PREFIX'], "lib", "python" + pyver)


		if 'PYTHONARCHDIR' in conf.environ:
			pyarchdir = conf.environ['PYTHONARCHDIR']
		else:
			(pyarchdir, ) = conf.get_python_variables( ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			if not pyarchdir:
				pyarchdir = pydir

		if hasattr(conf, 'define'): # conf.define is added by the C tool, so may not exist
			conf.define('PYTHONDIR', pydir)
			conf.define('PYTHONARCHDIR', pyarchdir)

		conf.env['PYTHONDIR'] = pydir
		conf.env['PYTHONARCHDIR'] = pyarchdir

	# Feedback
	pyver_full = '.'.join(map(str, pyver_tuple[:3]))
	if minver is None:
		conf.msg('Checking for python version', pyver_full)
	else:
		minver_str = '.'.join(map(str, minver))
		conf.msg('Checking for python version', pyver_tuple, ">= %s" % (minver_str,) and 'GREEN' or 'YELLOW')

	if not result:
		conf.fatal('The python version is too old, expecting %r' % (minver,))
Пример #26
0
def check_python_version(conf, minver=None):
	"""
	Check if the python interpreter is found matching a given minimum version.
	minver should be a tuple, eg. to check for python >= 2.4.2 pass (2,4,2) as minver.

	If successful, PYTHON_VERSION is defined as 'MAJOR.MINOR'
	(eg. '2.4') of the actual python version found, and PYTHONDIR is
	defined, pointing to the site-packages directory appropriate for
	this python version, where modules/packages/extensions should be
	installed.

	:param minver: minimum version
	:type minver: tuple of int
	"""
	assert minver is None or isinstance(minver, tuple)
	pybin = conf.env['PYTHON']
	if not pybin:
		conf.fatal('could not find the python executable')

	# Get python version string
	cmd = pybin + ['-c', 'import sys\nfor x in sys.version_info: print(str(x))']
	Logs.debug('python: Running python command %r' % cmd)
	lines = conf.cmd_and_log(cmd).split()
	assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
	pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))

	# compare python version with the minimum required
	result = (minver is None) or (pyver_tuple >= minver)

	if result:
		# define useful environment variables
		pyver = '.'.join([str(x) for x in pyver_tuple[:2]])
		conf.env['PYTHON_VERSION'] = pyver

		if 'PYTHONDIR' in conf.environ:
			pydir = conf.environ['PYTHONDIR']
		else:
			if Utils.is_win32:
				(python_LIBDEST, pydir) = conf.get_python_variables(
					  ["get_config_var('LIBDEST') or ''",
					   "get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			else:
				python_LIBDEST = None
				(pydir,) = conf.get_python_variables( ["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			if python_LIBDEST is None:
				if conf.env['LIBDIR']:
					python_LIBDEST = os.path.join(conf.env['LIBDIR'], "python" + pyver)
				else:
					python_LIBDEST = os.path.join(conf.env['PREFIX'], "lib", "python" + pyver)


		if 'PYTHONARCHDIR' in conf.environ:
			pyarchdir = conf.environ['PYTHONARCHDIR']
		else:
			(pyarchdir, ) = conf.get_python_variables( ["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']])
			if not pyarchdir:
				pyarchdir = pydir

		if hasattr(conf, 'define'): # conf.define is added by the C tool, so may not exist
			conf.define('PYTHONDIR', pydir)
			conf.define('PYTHONARCHDIR', pyarchdir)

		conf.env['PYTHONDIR'] = pydir
		conf.env['PYTHONARCHDIR'] = pyarchdir

	# Feedback
	pyver_full = '.'.join(map(str, pyver_tuple[:3]))
	if minver is None:
		conf.msg('Checking for python version', pyver_full)
	else:
		minver_str = '.'.join(map(str, minver))
		conf.msg('Checking for python version', pyver_tuple, ">= %s" % (minver_str,) and 'GREEN' or 'YELLOW')

	if not result:
		conf.fatal('The python version is too old, expecting %r' % (minver,))