Author: loonycyborg
Date: Tue Apr 29 18:28:31 2008
New Revision: 26229

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26229&view=rev
Log:
Added custom check for python.

Modified:
    trunk/SConstruct

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=26229&r1=26228&r2=26229&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Tue Apr 29 18:28:31 2008
@@ -246,6 +246,32 @@
         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 @@
     return False
 
 conf = Configure(env, custom_tests = { 'CheckCPlusPlus' : CheckCPlusPlus,
+                                       'CheckPython' : CheckPython,
                                        'CheckPKGConfig' : CheckPKGConfig,
                                        'CheckPKG' : CheckPKG,
                                        'CheckSDL' : CheckSDL,
@@ -395,8 +422,7 @@
     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


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to