Added custom check for python.

This commit is contained in:
Sergey Popov 2008-04-29 16:28:31 +00:00
parent 709cf9c94a
commit 75f986ad52

View file

@ -246,6 +246,32 @@ def CheckBoost(context, boost_lib, require_version = None):
context.Result("no")
return check_result
def CheckPython(context):
env = context.env
backup = backup_env(env, ["CPPPATH", "LIBPATH", "LIBS"])
context.Message("Checking for Python... ")
import distutils.sysconfig
env.AppendUnique(CPPPATH = distutils.sysconfig.get_python_inc())
version = distutils.sysconfig.get_config_var("VERSION")
if not version:
version = sys.version[:3]
env.AppendUnique(LIBPATH = distutils.sysconfig.get_config_var("LIBDIR"))
env.AppendUnique(LIBS = "python" + version)
test_program = """
#include <Python.h>
int main()
{
Py_Initialize();
}
\n"""
if context.TryLink(test_program, ".c"):
context.Result("yes")
return True
else:
context.Result("no")
restore_env(context.env, backup)
return False
def CheckSDL(context, sdl_lib = "SDL", require_version = None):
if require_version:
version = require_version.split(".", 2)
@ -365,6 +391,7 @@ def Warning(message):
return False
conf = Configure(env, custom_tests = { 'CheckCPlusPlus' : CheckCPlusPlus,
'CheckPython' : CheckPython,
'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG,
'CheckSDL' : CheckSDL,
@ -395,8 +422,7 @@ if env["prereqs"]:
have_server_prereqs = conf.CheckSDL('SDL_net') or Warning("Server prerequisites are not met. wesnothd and campaignd cannot be built.")
if env["python"]:
env["python"] = (float(sys.version[:3]) >= 2.4) and conf.CheckLib('python'+sys.version[:3]) or Warning("Python >= 2.4 not found. Python extensions will be disabled.")
env.Append(CPPPATH = ["/usr/include/python%s" % sys.version[:3]])
env["python"] = (float(sys.version[:3]) >= 2.4) and conf.CheckPython() or Warning("Python >= 2.4 not found. Python extensions will be disabled.")
else:
have_client_prereqs = True
have_X = True