Example #1
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""
	res = True

	if not getattr(Options.options, 'perlbinary', None):
		perl = conf.find_program("perl", var="PERL")
		if not perl:
			return False
	else:
		perl = Options.options.perlbinary
		conf.env['PERL'] = perl

	version = Utils.cmd_output(perl + " -e'printf \"%vd\", $^V'")
	if not version:
		res = False
		version = "Unknown"
	elif not minver is None:
		ver = tuple(map(int, version.split(".")))
		if ver < minver:
			res = False

	if minver is None:
		cver = ""
	else:
		cver = ".".join(map(str,minver))
	conf.check_message("perl", cver, res, version)
	return res
Example #2
0
def detect(conf):
  join = os.path.join
  abspath = os.path.abspath
  wafadmin = abspath(join(os.path.dirname(__file__), '..'))
  libnode = abspath(join(wafadmin, '..'))
  lib = abspath(join(libnode, '..'))
  prefix = abspath(join(lib, '..'))

  conf.env['PREFIX_NODE'] = prefix
  conf.env['LIBPATH_NODE'] = lib
  conf.env['CPPPATH_NODE'] = join(prefix, 'include/node')
  conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE'
  conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0'

  # with symbols
  conf.env.append_value('CCFLAGS', ['-g'])
  conf.env.append_value('CXXFLAGS', ['-g'])

  found = os.path.exists(join(prefix, "bin/node"))
  conf.check_message('node prefix', '', found, prefix)

  ## On Cygwin we need to link to the generated symbol definitions
  if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node'

  ## On Mac OSX we need to use mac bundles
  if Options.platform == 'darwin': conf.check_tool('osx')
Example #3
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

	if getattr(Options.options, 'perlbinary', None):
		conf.env.PERL = Options.options.perlbinary
	else:
		conf.find_program('perl', var='PERL', mandatory=True)

	try:
		version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')

	conf.env.PERL_VERSION = version
	cver = ''
	if minver:
		try:
			ver = tuple(map(int, version.split('.')))
		except:
			conf.fatal('unsupported perl version %r' % version)
		if ver < minver:
			conf.fatal('perl is too old')

		cver = '.'.join(map(str,minver))
	conf.check_message('perl', cver, True, version)
Example #4
0
def check_swig_version(conf, minver=None):
    """Check for a minimum swig version  like conf.check_swig_version('1.3.28')
	or conf.check_swig_version((1,3,28)) """
    reg_swig = re.compile(r'SWIG Version\s(.*)', re.M)

    swig_out = Utils.cmd_output('%s -version' % conf.env['SWIG'])

    swigver = [int(s) for s in reg_swig.findall(swig_out)[0].split('.')]
    if isinstance(minver, basestring):
        minver = [int(s) for s in minver.split(".")]
    if isinstance(minver, tuple):
        minver = [int(s) for s in minver]
    result = (minver is None) or (minver[:3] <= swigver[:3])
    swigver_full = '.'.join(map(str, swigver))
    if result:
        conf.env['SWIG_VERSION'] = swigver_full
    minver_str = '.'.join(map(str, minver))
    if minver is None:
        conf.check_message_custom('swig version', '', swigver_full)
    else:
        conf.check_message('swig version',
                           '>= %s' % (minver_str, ),
                           result,
                           option=swigver_full)
    return result
Example #5
0
def check_ruby_version(conf, minver=()):
    """
    Checks if ruby is installed.
    If installed the variable RUBY will be set in environment.
    Ruby binary can be overridden by --with-ruby-binary config variable
    """
    if Options.options.rubybinary:
        ruby = Options.options.rubybinary
    else:
        ruby = conf.find_program("ruby", var="RUBY")
        if not ruby:
            return False

    conf.env['RUBY'] = ruby

    res = True

    version = Utils.cmd_output(ruby + " -e 'puts defined?(VERSION) ? VERSION : RUBY_VERSION'").strip()
    if version and minver:
        conf.env['RUBY_VERSION'] = tuple(int(x) for x in version.split("."))
        res = not (conf.env['RUBY_VERSION'] < minver)

    if not version:
        version = "Unknown"

    cver = ".".join(str(x) for x in minver)

    conf.check_message('ruby', cver, res, version)

    return res
Example #6
0
def check_ruby_version(conf, minver=()):
	"""
	Checks if ruby is installed.
	If installed the variable RUBY will be set in environment.
	Ruby binary can be overridden by --with-ruby-binary config variable
	"""

	if Options.options.rubybinary:
		conf.env.RUBY = Options.options.rubybinary
	else:
		conf.find_program("ruby", var="RUBY", mandatory=True)

	ruby = conf.env.RUBY

	try:
		version = Utils.cmd_output([ruby, '-e', 'puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION = version

	try:
		ver = tuple(map(int, version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r' % version)

	cver = ''
	if minver:
		if ver < minver:
			conf.fatal('ruby is too old')
		cver = ".".join([str(x) for x in minver])

	conf.check_message('ruby', cver, True, version)
Example #7
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

	if getattr(Options.options, 'perlbinary', None):
		conf.env.PERL = Options.options.perlbinary
	else:
		conf.find_program('perl', var='PERL', mandatory=True)

	try:
		version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')

	conf.env.PERL_VERSION = version
	cver = ''
	if minver:
		try:
			ver = tuple(map(int, version.split('.')))
		except:
			conf.fatal('unsupported perl version %r' % version)
		if ver < minver:
			conf.fatal('perl is too old')

		cver = '.'.join(map(str,minver))
	conf.check_message('perl', cver, True, version)
Example #8
0
def check_perl_version(conf, minver=None):
    """
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""
    res = True

    if not getattr(Options.options, 'perlbinary', None):
        perl = conf.find_program("perl", var="PERL")
        if not perl:
            return False
    else:
        perl = Options.options.perlbinary
        conf.env['PERL'] = perl

    version = Utils.cmd_output(perl + " -e'printf \"%vd\", $^V'")
    if not version:
        res = False
        version = "Unknown"
    elif not minver is None:
        ver = tuple(map(int, version.split(".")))
        if ver < minver:
            res = False

    if minver is None:
        cver = ""
    else:
        cver = ".".join(map(str, minver))
    conf.check_message("perl", cver, res, version)
    return res
Example #9
0
File: perl.py Project: runt18/samba
def check_perl_version(conf, minver=None):
    """
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

    if getattr(Options.options, "perlbinary", None):
        conf.env.PERL = Options.options.perlbinary
    else:
        conf.find_program("perl", var="PERL", mandatory=True)

    try:
        version = Utils.cmd_output([conf.env.PERL, "-e", 'printf "%vd",$^V'])
    except:
        conf.fatal("could not determine the perl version")

    conf.env.PERL_VERSION = version
    cver = ""
    if minver:
        try:
            ver = tuple(map(int, version.split(".")))
        except:
            conf.fatal("unsupported perl version {0!r}".format(version))
        if ver < minver:
            conf.fatal("perl is too old")

        cver = ".".join(map(str, minver))
    conf.check_message("perl", cver, True, version)
Example #10
0
def check_ruby_version(conf, minver=()):
	"""
	Checks if ruby is installed.
	If installed the variable RUBY will be set in environment.
	Ruby binary can be overridden by --with-ruby-binary config variable
	"""

	if Options.options.rubybinary:
		conf.env.RUBY = Options.options.rubybinary
	else:
		conf.find_program("ruby", var="RUBY", mandatory=True)

	ruby = conf.env.RUBY

	try:
		version = Utils.cmd_output([ruby, '-e', 'puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION = version

	try:
		ver = tuple(map(int, version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r' % version)

	cver = ''
	if minver:
		if ver < minver:
			conf.fatal('ruby is too old')
		cver = ".".join([str(x) for x in minver])

	conf.check_message('ruby', cver, True, version)
Example #11
0
def detect(conf):
  join = os.path.join

  conf.env['PREFIX_NODE'] = get_prefix()
  prefix = conf.env['PREFIX_NODE']
  lib = join(prefix, 'lib')

  conf.env['LIBPATH_NODE'] = lib
  conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node')
  conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE'
  conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0'

  # with symbols
  conf.env.append_value('CCFLAGS', ['-g'])
  conf.env.append_value('CXXFLAGS', ['-g'])
  # install path
  conf.env['NODE_PATH'] = get_node_path()
  # this changes the install path of cxx task_gen
  conf.env['LIBDIR'] = conf.env['NODE_PATH']

  found = os.path.exists(conf.env['NODE_PATH'])
  conf.check_message('node path', '', found, conf.env['NODE_PATH'])

  found = os.path.exists(join(prefix, 'bin', 'node'))
  conf.check_message('node prefix', '', found, prefix)

  ## On Cygwin we need to link to the generated symbol definitions
  if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node'

  ## On Mac OSX we need to use mac bundles
  if Options.platform == 'darwin': conf.check_tool('osx')
Example #12
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.")
Example #13
0
def check_python_module(conf, module_name):
    result = not Utils.pproc.Popen(
        [conf.env["PYTHON"], "-c", "import %s" % module_name], stderr=Utils.pproc.PIPE, stdout=Utils.pproc.PIPE
    ).wait()
    conf.check_message("Python module", module_name, result)
    if not result:
        conf.fatal("Could not find the python module %r" % module_name)
Example #14
0
def check_python_module(conf, module_name):
    result = not Utils.pproc.Popen(
        [conf.env['PYTHON'], "-c",
         "import %s" % module_name],
        stderr=Utils.pproc.PIPE,
        stdout=Utils.pproc.PIPE).wait()
    conf.check_message('Python module', module_name, result)
    if not result:
        conf.fatal('Could not find the python module %r' % module_name)
Example #15
0
def check_python_module(conf, module_name):
	"""
	Check if the selected python interpreter can import the given python module.
	"""
	result = not Utils.pproc.Popen([conf.env['PYTHON'], "-c", "import %s" % module_name],
			   stderr=Utils.pproc.PIPE, stdout=Utils.pproc.PIPE).wait()
	conf.check_message('Python module', module_name, result)
	if not result:
		conf.fatal('Could not find the python module %r' % module_name)
Example #16
0
def check_python_module(conf, module_name):
	"""
	Check if the selected python interpreter can import the given python module.
	"""
	result = not Utils.pproc.Popen([conf.env['PYTHON'], "-c", "import %s" % module_name],
			   stderr=Utils.pproc.PIPE, stdout=Utils.pproc.PIPE).wait()
	conf.check_message('Python module', module_name, result)
	if not result:
		conf.fatal('Could not find the python module %r' % module_name)
Example #17
0
def check_python_module(conf,module_name):
	argv=[conf.env['PYTHON'],"-c","import %s"%module_name]
	proc=Utils.pproc.Popen(argv,stderr=Utils.pproc.PIPE)
	stderr=proc.stderr.read()
	retval=proc.wait()
	result=(retval==0)
	conf.check_message('Python module',module_name,result)
	if not result:
		conf.log.write("Process %r returned exit code %i:\n-- \n%s\n-- \n"%(argv,retval,stderr))
		conf.fatal("Python module not found.")
Example #18
0
def check_python_module(conf, module_name):
    argv = [conf.env['PYTHON'], "-c", "import %s" % module_name]
    proc = Utils.pproc.Popen(argv, stderr=Utils.pproc.PIPE)
    stderr = proc.stderr.read()
    retval = proc.wait()
    result = (retval == 0)
    conf.check_message('Python module', module_name, result)
    if not result:
        conf.log.write("Process %r returned exit code %i:\n-- \n%s\n-- \n" %
                       (argv, retval, stderr))
        conf.fatal("Python module not found.")
Example #19
0
def check_perl_module(conf, module):
	"""
	Check if specified perlmodule is installed.

	Minimum version can be specified by specifying it after modulename
	like this:

	conf.check_perl_module("Some::Module 2.92")
	"""
	cmd = [conf.env['PERL'], '-e', 'use %s' % module]
	r = Utils.pproc.call(cmd, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE) == 0
	conf.check_message("perl module %s" % module, "", r)
	return r
Example #20
0
def check_perl_module(conf, module):
	"""
	Check if specified perlmodule is installed.

	Minimum version can be specified by specifying it after modulename
	like this:

	conf.check_perl_module("Some::Module 2.92")
	"""
	cmd = [conf.env['PERL'], '-e', 'use %s' % module]
	r = pproc.call(cmd, stdout=pproc.PIPE, stderr=pproc.PIPE) == 0
	conf.check_message("perl module %s" % module, "", r)
	return r
Example #21
0
File: perl.py Project: runt18/samba
def check_perl_module(conf, module):
    """
	Check if specified perlmodule is installed.

	Minimum version can be specified by specifying it after modulename
	like this:

	conf.check_perl_module("Some::Module 2.92")
	"""
    cmd = [conf.env["PERL"], "-e", "use {0!s}".format(module)]
    r = Utils.pproc.call(cmd, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE) == 0
    conf.check_message("perl module {0!s}".format(module), "", r)
    return r
Example #22
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)
Example #23
0
def detect(conf):
  join = os.path.join

  conf.env['PREFIX_NODE'] = get_prefix()
  prefix = conf.env['PREFIX_NODE']
  lib = join(prefix, 'lib')
  nodebin = join(prefix, 'bin', 'node')

  conf.env['LIBPATH_NODE'] = lib
  conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node')

  conf.env.append_value('CPPFLAGS_NODE', '-D_GNU_SOURCE')

  conf.env.append_value('CCFLAGS_NODE', '-D_LARGEFILE_SOURCE')
  conf.env.append_value('CCFLAGS_NODE', '-D_FILE_OFFSET_BITS=64')

  conf.env.append_value('CXXFLAGS_NODE', '-D_LARGEFILE_SOURCE')
  conf.env.append_value('CXXFLAGS_NODE', '-D_FILE_OFFSET_BITS=64')

  # with symbols
  conf.env.append_value('CCFLAGS', ['-g'])
  conf.env.append_value('CXXFLAGS', ['-g'])
  # install path
  conf.env['NODE_PATH'] = get_node_path()
  # this changes the install path of cxx task_gen
  conf.env['LIBDIR'] = conf.env['NODE_PATH']

  found = os.path.exists(conf.env['NODE_PATH'])
  conf.check_message('node path', '', found, conf.env['NODE_PATH'])

  found = os.path.exists(nodebin)
  conf.check_message('node prefix', '', found, prefix)

  ## On Cygwin we need to link to the generated symbol definitions
  if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node'

  ## On Mac OSX we need to use mac bundles
  if Options.platform == 'darwin':
    if 'i386' in Utils.cmd_output(['file', nodebin]):
      conf.env.append_value('CPPFLAGS_NODE', ['-arch', 'i386'])
      conf.env.append_value('CXXFLAGS_NODE', ['-arch', 'i386'])
      conf.env.append_value('LINKFLAGS', ['-arch', 'i386'])
      conf.env['DEST_CPU'] = 'i386'
    conf.check_tool('osx')
Example #24
0
def CHECK_NEED_LC(conf, msg):
    '''check if we need -lc'''

    dir = find_config_dir(conf)

    env = conf.env

    bdir = os.path.join(dir, 'testbuild2')
    if not os.path.exists(bdir):
        os.makedirs(bdir)

    subdir = os.path.join(dir, "liblctest")

    os.makedirs(subdir)

    dest = open(os.path.join(subdir, 'liblc1.c'), 'w')
    dest.write(
        '#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n'
    )
    dest.close()

    bld = Build.BuildContext()
    bld.log = conf.log
    bld.all_envs.update(conf.all_envs)
    bld.all_envs['default'] = env
    bld.lst_variants = bld.all_envs.keys()
    bld.load_dirs(dir, bdir)

    bld.rescan(bld.srcnode)

    bld(features='cc cshlib',
        source='liblctest/liblc1.c',
        ldflags=conf.env['EXTRA_LDFLAGS'],
        target='liblc',
        name='liblc')

    try:
        bld.compile()
        conf.check_message(msg, '', True)
        return True
    except:
        conf.check_message(msg, '', False)
        return False
Example #25
0
def detect(conf):
  join = os.path.join
  abspath = os.path.abspath
  wafadmin = abspath(join(os.path.dirname(__file__), '..'))
  libnode = abspath(join(wafadmin, '..'))
  lib = abspath(join(libnode, '..'))
  prefix = abspath(join(lib, '..'))

  conf.env['PREFIX_NODE'] = prefix
  conf.env['LIBPATH_NODE'] = lib
  conf.env['CPPPATH_NODE'] = join(prefix, 'include/node')
  conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE'
  conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0'

  found = os.path.exists(join(prefix, "bin/node"))
  conf.check_message('node prefix', '', found, prefix)

  ## On Mac OSX we need to use mac bundles
  if Options.platform == 'darwin': conf.check_tool('osx')
Example #26
0
def CHECK_NEED_LC(conf, msg):
    '''check if we need -lc'''

    dir = find_config_dir(conf)

    env = conf.env

    bdir = os.path.join(dir, 'testbuild2')
    if not os.path.exists(bdir):
        os.makedirs(bdir)


    subdir = os.path.join(dir, "liblctest")

    os.makedirs(subdir)

    dest = open(os.path.join(subdir, 'liblc1.c'), 'w')
    dest.write('#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
    dest.close()

    bld = Build.BuildContext()
    bld.log = conf.log
    bld.all_envs.update(conf.all_envs)
    bld.all_envs['default'] = env
    bld.lst_variants = bld.all_envs.keys()
    bld.load_dirs(dir, bdir)

    bld.rescan(bld.srcnode)

    bld(features='cc cshlib',
        source='liblctest/liblc1.c',
        ldflags=conf.env['EXTRA_LDFLAGS'],
        target='liblc',
        name='liblc')

    try:
        bld.compile()
        conf.check_message(msg, '', True)
        return True
    except:
        conf.check_message(msg, '', False)
        return False
Example #27
0
File: perl.py Project: NKSG/ns3
def check_perl_version(conf,minver=None):
	if getattr(Options.options,'perlbinary',None):
		conf.env.PERL=Options.options.perlbinary
	else:
		conf.find_program('perl',var='PERL',mandatory=True)
	try:
		version=Utils.cmd_output([conf.env.PERL,'-e','printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')
	conf.env.PERL_VERSION=version
	cver=''
	if minver:
		try:
			ver=tuple(map(int,version.split('.')))
		except:
			conf.fatal('unsupported perl version %r'%version)
		if ver<minver:
			conf.fatal('perl is too old')
		cver='.'.join(map(str,minver))
	conf.check_message('perl',cver,True,version)
Example #28
0
def check_perl_version(conf, minver=None):
    if getattr(Options.options, 'perlbinary', None):
        conf.env.PERL = Options.options.perlbinary
    else:
        conf.find_program('perl', var='PERL', mandatory=True)
    try:
        version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
    except:
        conf.fatal('could not determine the perl version')
    conf.env.PERL_VERSION = version
    cver = ''
    if minver:
        try:
            ver = tuple(map(int, version.split('.')))
        except:
            conf.fatal('unsupported perl version %r' % version)
        if ver < minver:
            conf.fatal('perl is too old')
        cver = '.'.join(map(str, minver))
    conf.check_message('perl', cver, True, version)
Example #29
0
def check_ruby_version(conf,minver=()):
	if Options.options.rubybinary:
		conf.env.RUBY=Options.options.rubybinary
	else:
		conf.find_program("ruby",var="RUBY",mandatory=True)
	ruby=conf.env.RUBY
	try:
		version=Utils.cmd_output([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION=version
	try:
		ver=tuple(map(int,version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r'%version)
	cver=''
	if minver:
		if ver<minver:
			conf.fatal('ruby is too old')
		cver=".".join([str(x)for x in minver])
	conf.check_message('ruby',cver,True,version)
Example #30
0
File: ruby.py Project: NKSG/ns3
def check_ruby_version(conf,minver=()):
	if Options.options.rubybinary:
		conf.env.RUBY=Options.options.rubybinary
	else:
		conf.find_program("ruby",var="RUBY",mandatory=True)
	ruby=conf.env.RUBY
	try:
		version=Utils.cmd_output([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION=version
	try:
		ver=tuple(map(int,version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r'%version)
	cver=''
	if minver:
		if ver<minver:
			conf.fatal('ruby is too old')
		cver=".".join(str(x)for x in minver)
	conf.check_message('ruby',cver,True,version)
Example #31
0
def detect(conf):
    join = os.path.join

    conf.env["PREFIX_NODE"] = get_prefix()
    prefix = conf.env["PREFIX_NODE"]
    lib = join(prefix, "lib")

    conf.env["LIBPATH_NODE"] = lib
    conf.env["CPPPATH_NODE"] = join(prefix, "include", "node")

    conf.env.append_value("CPPFLAGS_NODE", "-D_GNU_SOURCE")
    conf.env.append_value("CPPFLAGS_NODE", "-DEV_MULTIPLICITY=0")

    conf.env.append_value("CCFLAGS_NODE", "-D_LARGEFILE_SOURCE")
    conf.env.append_value("CCFLAGS_NODE", "-D_FILE_OFFSET_BITS=64")

    conf.env.append_value("CXXFLAGS_NODE", "-D_LARGEFILE_SOURCE")
    conf.env.append_value("CXXFLAGS_NODE", "-D_FILE_OFFSET_BITS=64")

    # with symbols
    conf.env.append_value("CCFLAGS", ["-g"])
    conf.env.append_value("CXXFLAGS", ["-g"])
    # install path
    conf.env["NODE_PATH"] = get_node_path()
    # this changes the install path of cxx task_gen
    conf.env["LIBDIR"] = conf.env["NODE_PATH"]

    found = os.path.exists(conf.env["NODE_PATH"])
    conf.check_message("node path", "", found, conf.env["NODE_PATH"])

    found = os.path.exists(join(prefix, "bin", "node"))
    conf.check_message("node prefix", "", found, prefix)

    ## On Cygwin we need to link to the generated symbol definitions
    if Options.platform.startswith("cygwin"):
        conf.env["LIB_NODE"] = "node"

    ## On Mac OSX we need to use mac bundles
    if Options.platform == "darwin":
        conf.check_tool("osx")
Example #32
0
def check_swig_version(conf, minver=None):
	"""Check for a minimum swig version like conf.check_swig_version('1.3.28')
	or conf.check_swig_version((1,3,28)) """
	reg_swig = re.compile(r'SWIG Version\s(.*)', re.M)

	swig_out = Utils.cmd_output('%s -version' % conf.env['SWIG'])

	swigver = [int(s) for s in reg_swig.findall(swig_out)[0].split('.')]
	if isinstance(minver, basestring):
		minver = [int(s) for s in minver.split(".")]
	if isinstance(minver, tuple):
		minver = [int(s) for s in minver]
	result = (minver is None) or (minver[:3] <= swigver[:3])
	swigver_full = '.'.join(map(str, swigver))
	if result:
		conf.env['SWIG_VERSION'] = swigver_full
	minver_str = '.'.join(map(str, minver))
	if minver is None:
		conf.check_message_custom('swig version', '', swigver_full)
	else:
		conf.check_message('swig version', '>= %s' % (minver_str,), result, option=swigver_full)
	return result
Example #33
0
def check_java_class(conf,classname,with_classpath=None):
	class_check_source="""
public class Test {
	public static void main(String[] argv) {
		Class lib;
		if (argv.length < 1) {
			System.err.println("Missing argument");
			System.exit(77);
		}
		try {
			lib = Class.forName(argv[0]);
		} catch (ClassNotFoundException e) {
			System.err.println("ClassNotFoundException");
			System.exit(1);
		}
		lib = null;
		System.exit(0);
	}
}
"""
	import shutil
	javatestdir='.waf-javatest'
	classpath=javatestdir
	if conf.env['CLASSPATH']:
		classpath+=os.pathsep+conf.env['CLASSPATH']
	if isinstance(with_classpath,str):
		classpath+=os.pathsep+with_classpath
	shutil.rmtree(javatestdir,True)
	os.mkdir(javatestdir)
	java_file=open(os.path.join(javatestdir,'Test.java'),'w')
	java_file.write(class_check_source)
	java_file.close()
	os.popen(conf.env['JAVAC']+' '+os.path.join(javatestdir,'Test.java'))
	(jstdin,jstdout,jstderr)=os.popen3(conf.env['JAVA']+' -cp '+classpath+' Test '+classname)
	found=not bool(jstderr.read())
	conf.check_message('Java class %s'%classname,"",found)
	shutil.rmtree(javatestdir,True)
	return found
Example #34
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.")
Example #35
0
def check_perl_version(conf,minver=None):
	res=True
	if not getattr(Options.options,'perlbinary',None):
		perl=conf.find_program("perl",var="PERL")
		if not perl:
			return False
	else:
		perl=Options.options.perlbinary
		conf.env['PERL']=perl
	version=Utils.cmd_output(perl+" -e'printf \"%vd\", $^V'")
	if not version:
		res=False
		version="Unknown"
	elif not minver is None:
		ver=tuple(map(int,version.split(".")))
		if ver<minver:
			res=False
	if minver is None:
		cver=""
	else:
		cver=".".join(map(str,minver))
	conf.check_message("perl",cver,res,version)
	return res
Example #36
0
def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
    '''see if the platform supports building libraries'''

    if msg is None:
        if rpath:
            msg = "rpath library support"
        else:
            msg = "building library support"

    dir = find_config_dir(conf)

    bdir = os.path.join(dir, 'testbuild')
    if not os.path.exists(bdir):
        os.makedirs(bdir)

    env = conf.env

    subdir = os.path.join(dir, "libdir")

    os.makedirs(subdir)

    dest = open(os.path.join(subdir, 'lib1.c'), 'w')
    dest.write('int lib_func(void) { return 42; }\n')
    dest.close()

    dest = open(os.path.join(dir, 'main.c'), 'w')
    dest.write('int main(void) {return !(lib_func() == 42);}\n')
    dest.close()

    bld = Build.BuildContext()
    bld.log = conf.log
    bld.all_envs.update(conf.all_envs)
    bld.all_envs['default'] = env
    bld.lst_variants = bld.all_envs.keys()
    bld.load_dirs(dir, bdir)

    bld.rescan(bld.srcnode)

    ldflags = []
    if version_script:
        ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
        dest = open(os.path.join(dir,'vscript'), 'w')
        dest.write('TEST_1.0A2 { global: *; };\n')
        dest.close()

    bld(features='cc cshlib',
        source='libdir/lib1.c',
        target='libdir/lib1',
        ldflags=ldflags,
        name='lib1')

    o = bld(features='cc cprogram',
            source='main.c',
            target='prog1',
            uselib_local='lib1')

    if rpath:
        o.rpath=os.path.join(bdir, 'default/libdir')

    # compile the program
    try:
        bld.compile()
    except:
        conf.check_message(msg, '', False)
        return False

    # path for execution
    lastprog = o.link_task.outputs[0].abspath(env)

    if not rpath:
        if 'LD_LIBRARY_PATH' in os.environ:
            old_ld_library_path = os.environ['LD_LIBRARY_PATH']
        else:
            old_ld_library_path = None
        ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir'))

    # we need to run the program, try to get its result
    args = conf.SAMBA_CROSS_ARGS(msg=msg)
    proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)
    (out, err) = proc.communicate()
    w = conf.log.write
    w(str(out))
    w('\n')
    w(str(err))
    w('\nreturncode %r\n' % proc.returncode)
    ret = (proc.returncode == 0)

    if not rpath:
        os.environ['LD_LIBRARY_PATH'] = old_ld_library_path or ''

    conf.check_message(msg, '', ret)
    return ret
Example #37
0
def check_ruby_ext_devel(conf):
    if not (conf.env['RUBY'] and conf.env['RUBY_VERSION']):
        return False


    ruby = conf.env['RUBY']
    version = conf.env['RUBY_VERSION']

    def ruby_get_config(key):
        return Utils.cmd_output(ruby + " -rrbconfig -e 'print Config::CONFIG[\"" + key + "\"]'").strip()

    if version >= (1, 9, 0):
        ruby_h = Utils.cmd_output(ruby + " -rrbconfig -e 'puts File.exist?(Config::CONFIG[\"rubyhdrdir\"] + \"/ruby.h\")'").strip()
    elif version >= (1, 8, 0):
        ruby_h = Utils.cmd_output(ruby + " -rrbconfig -e 'puts File.exist?(Config::CONFIG[\"archdir\"] + \"/ruby.h\")'").strip()

    if ruby_h != 'true':
        conf.check_message('ruby', 'header file', False)
        return False

    conf.check_message('ruby', 'header file', True)

    archdir = Utils.cmd_output(ruby + " -rrbconfig -e 'puts \"%s\" % [].fill(Config::CONFIG[\"archdir\"], 0..1)'").strip()
    conf.env["CPPPATH_RUBY"] = [archdir]
    conf.env["LINKFLAGS_RUBY"] = '-L%s' % archdir

    if version >= (1, 9, 0):
        incpaths = Utils.cmd_output(ruby + " -rrbconfig -e 'puts Config::CONFIG[\"rubyhdrdir\"]'").strip()
        conf.env["CPPPATH_RUBY"] += [incpaths]

        incpaths = Utils.cmd_output(ruby + " -rrbconfig -e 'puts File.join(Config::CONFIG[\"rubyhdrdir\"], Config::CONFIG[\"arch\"])'").strip()
        conf.env["CPPPATH_RUBY"] += [incpaths]

    ldflags = Utils.cmd_output(ruby + " -rrbconfig -e 'print Config::CONFIG[\"LDSHARED\"]'").strip()

    # ok this is really stupid, but the command and flags are combined.
    # so we try to find the first argument...
    flags = ldflags.split()
    while flags and flags[0][0] != '-':
        flags = flags[1:]

    # we also want to strip out the deprecated ppc flags
    if len(flags) > 1 and flags[1] == "ppc":
        flags = flags[2:]

    conf.env["LINKFLAGS_RUBY"] += " " + " ".join(flags)

    ldflags = ruby_get_config("LIBS")
    conf.env["LINKFLAGS_RUBY"] += " " + ldflags
    
    ldflags = ruby_get_config("LIBRUBYARG_SHARED")
    conf.env["LINKFLAGS_RUBY"] += " " + ldflags

    cflags = ruby_get_config("CCDLFLAGS")
    conf.env["CCFLAGS_RUBY"] = cflags

    if Options.options.rubyarchdir:
        conf.env["ARCHDIR_RUBY"] = Options.options.rubyarchdir
    else:
        conf.env["ARCHDIR_RUBY"] = Utils.cmd_output(ruby + " -rrbconfig -e 'print Config::CONFIG[\"sitearchdir\"]'").strip()

    if Options.options.rubylibdir:
        conf.env["LIBDIR_RUBY"] = Options.options.rubylibdir
    else:
        conf.env["LIBDIR_RUBY"] = Utils.cmd_output(ruby + " -rrbconfig -e 'print Config::CONFIG[\"sitelibdir\"]'").strip()

    conf.env['rubyext_PATTERN'] = '%s.' + Utils.cmd_output(ruby + " -rrbconfig -e 'print Config::CONFIG[\"DLEXT\"]'").strip()

    # Change some strings to a list
    conf.env["LINKFLAGS_RUBY"] = Utils.to_list(conf.env["LINKFLAGS_RUBY"])
    conf.env["CPPPATH_RUBY"] = Utils.to_list(conf.env["CPPPATH_RUBY"])
    conf.env["CCFLAGS_RUBY"] = Utils.to_list(conf.env["CCFLAGS_RUBY"])

    return True
def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
    '''see if the platform supports building libraries'''

    if msg is None:
        if rpath:
            msg = "rpath library support"
        else:
            msg = "building library support"

    dir = find_config_dir(conf)

    bdir = os.path.join(dir, 'testbuild')
    if not os.path.exists(bdir):
        os.makedirs(bdir)

    env = conf.env

    subdir = os.path.join(dir, "libdir")

    os.makedirs(subdir)

    dest = open(os.path.join(subdir, 'lib1.c'), 'w')
    dest.write('int lib_func(void) { return 42; }\n')
    dest.close()

    dest = open(os.path.join(dir, 'main.c'), 'w')
    dest.write('int main(void) {return !(lib_func() == 42);}\n')
    dest.close()

    bld = Build.BuildContext()
    bld.log = conf.log
    bld.all_envs.update(conf.all_envs)
    bld.all_envs['default'] = env
    bld.lst_variants = bld.all_envs.keys()
    bld.load_dirs(dir, bdir)

    bld.rescan(bld.srcnode)

    ldflags = []
    if version_script:
        ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
        dest = open(os.path.join(dir,'vscript'), 'w')
        dest.write('TEST_1.0A2 { global: *; };\n')
        dest.close()

    bld(features='cc cshlib',
        source='libdir/lib1.c',
        target='libdir/lib1',
        ldflags=ldflags,
        name='lib1')

    o = bld(features='cc cprogram',
            source='main.c',
            target='prog1',
            uselib_local='lib1')

    if rpath:
        o.rpath=os.path.join(bdir, 'default/libdir')

    # compile the program
    try:
        bld.compile()
    except:
        conf.check_message(msg, '', False)
        return False

    # path for execution
    lastprog = o.link_task.outputs[0].abspath(env)

    if not rpath:
        if 'LD_LIBRARY_PATH' in os.environ:
            old_ld_library_path = os.environ['LD_LIBRARY_PATH']
        else:
            old_ld_library_path = None
        ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir'))

    # we need to run the program, try to get its result
    args = conf.SAMBA_CROSS_ARGS(msg=msg)
    proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)
    (out, err) = proc.communicate()
    w = conf.log.write
    w(str(out))
    w('\n')
    w(str(err))
    w('\nreturncode %r\n' % proc.returncode)
    ret = (proc.returncode == 0)

    if not rpath:
        os.environ['LD_LIBRARY_PATH'] = old_ld_library_path or ''

    conf.check_message(msg, '', ret)
    return ret
Example #39
0
File: perl.py Project: NKSG/ns3
def check_perl_module(conf,module):
	cmd=[conf.env['PERL'],'-e','use %s'%module]
	r=Utils.pproc.call(cmd,stdout=Utils.pproc.PIPE,stderr=Utils.pproc.PIPE)==0
	conf.check_message("perl module %s"%module,"",r)
	return r
Example #40
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)
Example #41
0
def check_perl_module(conf, module):
    cmd = [conf.env['PERL'], '-e', 'use %s' % module]
    r = Utils.pproc.call(cmd, stdout=Utils.pproc.PIPE,
                         stderr=Utils.pproc.PIPE) == 0
    conf.check_message("perl module %s" % module, "", r)
    return r
def check_python_module(conf,module_name):
	result=not Utils.pproc.Popen([conf.env['PYTHON'],"-c","import %s"%module_name],stderr=Utils.pproc.PIPE,stdout=Utils.pproc.PIPE).wait()
	conf.check_message('Python module',module_name,result)
	if not result:
		conf.fatal("Python module not found.")
Example #43
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)