Beispiel #1
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    python = conf.env['PYTHON']
    assert python, ("python is %r !" % (python, ))
    cmd = [
        python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"
    ]
    debug('python: Running python command %r' % cmd)
    proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE)
    lines = proc.communicate()[0].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 sys.platform == 'win32':
                (
                    python_LIBDEST, pydir
                ) = _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, ) = _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('PYTHONDIR', pydir)
        conf.env['PYTHONDIR'] = pydir
    pyver_full = '.'.join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.check_message_custom('Python version', '', pyver_full)
    else:
        minver_str = '.'.join(map(str, minver))
        conf.check_message('Python version',
                           ">= %s" % (minver_str, ),
                           result,
                           option=pyver_full)
    if not result:
        conf.fatal("Python too old.")
Beispiel #2
0
def CHECK_LIB(conf,
              libs,
              mandatory=False,
              empty_decl=True,
              set_target=True,
              shlib=False):
    '''check if a set of libraries exist as system libraries

    returns the sublist of libs that do exist as a syslib or []
    '''

    fragment = '''
int foo()
{
    int v = 2;
    return v*2;
}
'''
    ret = []
    liblist = TO_LIST(libs)
    for lib in liblist[:]:
        if GET_TARGET_TYPE(conf, lib) == 'SYSLIB':
            ret.append(lib)
            continue

        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
        if shlib:
            res = conf.check(features='cc cshlib',
                             fragment=fragment,
                             lib=lib,
                             uselib_store=lib,
                             ccflags=ccflags,
                             ldflags=ldflags,
                             uselib=lib.upper())
        else:
            res = conf.check(lib=lib,
                             uselib_store=lib,
                             ccflags=ccflags,
                             ldflags=ldflags,
                             uselib=lib.upper())

        if not res:
            if mandatory:
                Logs.error(
                    "Mandatory library '%s' not found for functions '%s'" %
                    (lib, list))
                sys.exit(1)
            if empty_decl:
                # if it isn't a mandatory library, then remove it from dependency lists
                if set_target:
                    SET_TARGET_TYPE(conf, lib, 'EMPTY')
        else:
            conf.define('HAVE_LIB%s' % lib.upper().replace('-', '_'), 1)
            conf.env['LIB_' + lib.upper()] = lib
            if set_target:
                conf.SET_TARGET_TYPE(lib, 'SYSLIB')
            ret.append(lib)

    return ret
Beispiel #3
0
def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True, shlib=False):
    """check if a set of libraries exist as system libraries

    returns the sublist of libs that do exist as a syslib or []
    """

    fragment = """
int foo()
{
    int v = 2;
    return v*2;
}
"""
    ret = []
    liblist = TO_LIST(libs)
    for lib in liblist[:]:
        if GET_TARGET_TYPE(conf, lib) == "SYSLIB":
            ret.append(lib)
            continue

        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
        if shlib:
            res = conf.check(
                features="c cshlib",
                fragment=fragment,
                lib=lib,
                uselib_store=lib,
                ccflags=ccflags,
                ldflags=ldflags,
                uselib=lib.upper(),
                mandatory=False,
            )
        else:
            res = conf.check(
                lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper(), mandatory=False
            )

        if not res:
            if mandatory:
                Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                sys.exit(1)
            if empty_decl:
                # if it isn't a mandatory library, then remove it from dependency lists
                if set_target:
                    SET_TARGET_TYPE(conf, lib, "EMPTY")
        else:
            conf.define("HAVE_LIB%s" % lib.upper().replace("-", "_").replace(".", "_"), 1)
            conf.env["LIB_" + lib.upper()] = lib
            if set_target:
                conf.SET_TARGET_TYPE(lib, "SYSLIB")
            ret.append(lib)

    return ret
Beispiel #4
0
def check_python_version(conf, minver=None):
    assert minver is None or isinstance(minver, tuple)
    python = conf.env["PYTHON"]
    if not python:
        conf.fatal("could not find the python executable")
    cmd = [python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"]
    debug("python: Running python command %r" % cmd)
    proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE)
    lines = proc.communicate()[0].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 sys.platform == "win32":
                (python_LIBDEST, pydir) = _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,) = _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("PYTHONDIR", pydir)
        conf.env["PYTHONDIR"] = pydir
    pyver_full = ".".join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.check_message_custom("Python version", "", pyver_full)
    else:
        minver_str = ".".join(map(str, minver))
        conf.check_message("Python version", ">= %s" % minver_str, result, option=pyver_full)
    if not result:
        conf.fatal("The python version is too old (%r)" % pyver_full)
def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True, set_target=True, shlib=False):
    '''check if a set of libraries exist as system libraries

    returns the sublist of libs that do exist as a syslib or []
    '''

    fragment= '''
int foo()
{
    int v = 2;
    return v*2;
}
'''
    ret = []
    liblist  = TO_LIST(libs)
    for lib in liblist[:]:
        if GET_TARGET_TYPE(conf, lib) == 'SYSLIB':
            ret.append(lib)
            continue

        (ccflags, ldflags, cpppath) = library_flags(conf, lib)
        if lib == 'menu' or lib == 'panel' or lib == 'form':
            ldflags  = '-lncurses'            
        
        if shlib:
            res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
        else:
            res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())

        if not res:
            if mandatory:
                Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                sys.exit(1)
            if empty_decl:
                # if it isn't a mandatory library, then remove it from dependency lists
                if set_target:
                    SET_TARGET_TYPE(conf, lib, 'EMPTY')
        else:
            conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1)
            conf.env['LIB_' + lib.upper()] = lib
            if set_target:
                conf.SET_TARGET_TYPE(lib, 'SYSLIB')
            ret.append(lib)

    return ret
Beispiel #6
0
def check_python_version(conf,minver=None):
	assert minver is None or isinstance(minver,tuple)
	python=conf.env['PYTHON']
	assert python,("python is %r !"%(python,))
	cmd=[python,"-c","import sys\nfor x in sys.version_info: print(str(x))"]
	debug('python: Running python command %r'%cmd)
	proc=Utils.pproc.Popen(cmd,stdout=Utils.pproc.PIPE)
	lines=proc.communicate()[0].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 sys.platform=='win32':
				(python_LIBDEST,pydir)=_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,)=_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('PYTHONDIR',pydir)
		conf.env['PYTHONDIR']=pydir
	pyver_full='.'.join(map(str,pyver_tuple[:3]))
	if minver is None:
		conf.check_message_custom('Python version','',pyver_full)
	else:
		minver_str='.'.join(map(str,minver))
		conf.check_message('Python version',">= %s"%(minver_str,),result,option=pyver_full)
	if not result:
		conf.fatal("Python too old.")
Beispiel #7
0
def DEFINE(conf, d, v, add_to_cflags=False, quote=False):
    '''define a config option'''
    conf.define(d, v, quote=quote)
    if add_to_cflags:
        conf.env.append_value('CCDEFINES', d + '=' + str(v))
Beispiel #8
0
def DEFINE(conf, d, v, add_to_cflags=False, quote=False):
    '''define a config option'''
    conf.define(d, v, quote=quote)
    if add_to_cflags:
        conf.env.append_value('CCDEFINES', d + '=' + str(v))
Beispiel #9
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.
	"""
	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)
	proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE, shell=False)
	lines = proc.communicate()[0].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) = \
						_get_python_variables(python,
											  ["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,) = \
						_get_python_variables(python,
											  ["get_python_lib(standard_lib=0, prefix=%r) or ''" % 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 'PYTHONARCHDIR' in conf.environ:
			pyarchdir = conf.environ['PYTHONARCHDIR']
		else:
			(pyarchdir,) = _get_python_variables(python,
											["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env['PREFIX']],
											['from distutils.sysconfig import get_config_var, get_python_lib'])
			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

	# Feedback
	pyver_full = '.'.join(map(str, pyver_tuple[:3]))
	if minver is None:
		conf.check_message_custom('Python version', '', pyver_full)
	else:
		minver_str = '.'.join(map(str, minver))
		conf.check_message('Python version', ">= %s" % minver_str, result, option=pyver_full)

	if not result:
		conf.fatal('The python version is too old (%r)' % pyver_full)
Beispiel #10
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.
	"""
    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)
    proc = Utils.pproc.Popen(cmd, stdout=Utils.pproc.PIPE, shell=False)
    lines = proc.communicate()[0].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) = \
                  _get_python_variables(python,
                         ["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,) = \
                  _get_python_variables(python,
                         ["get_python_lib(standard_lib=0, prefix=%r) or ''" % 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 'PYTHONARCHDIR' in conf.environ:
            pyarchdir = conf.environ['PYTHONARCHDIR']
        else:
            (pyarchdir, ) = _get_python_variables(python, [
                "get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''"
                % conf.env['PREFIX']
            ], [
                'from distutils.sysconfig import get_config_var, get_python_lib'
            ])
            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

    # Feedback
    pyver_full = '.'.join(map(str, pyver_tuple[:3]))
    if minver is None:
        conf.check_message_custom('Python version', '', pyver_full)
    else:
        minver_str = '.'.join(map(str, minver))
        conf.check_message('Python version',
                           ">= %s" % minver_str,
                           result,
                           option=pyver_full)

    if not result:
        conf.fatal('The python version is too old (%r)' % pyver_full)
Beispiel #11
0
def DEFINE(conf, d, v, add_to_cflags=False, quote=False):
    """define a config option"""
    conf.define(d, v, quote=quote)
    if add_to_cflags:
        conf.env.append_value("CCDEFINES", d + "=" + str(v))