Added custom check for python.
This commit is contained in:
parent
709cf9c94a
commit
75f986ad52
1 changed files with 28 additions and 2 deletions
30
SConstruct
30
SConstruct
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue