コード例 #1
0
ファイル: python.py プロジェクト: sw1001/rapidnet-beta
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.")
コード例 #2
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
コード例 #3
0
ファイル: python.py プロジェクト: juanrgar/hamster
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)
コード例 #4
0
ファイル: swig.py プロジェクト: DanilKorotenko/samba
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
コード例 #5
0
ファイル: python.py プロジェクト: diedthreetimes/VCrash
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.")
コード例 #6
0
ファイル: python.py プロジェクト: farthought/waf15
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)
コード例 #7
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)