Bug 1200 - ./waf install doesn't install Python bindings properly
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 11 Jul 2011 14:24:59 +0100
changeset 7363 0f96f5beb8c7
parent 7362 36b42a8b16d1
child 7364 80940903b711
Bug 1200 - ./waf install doesn't install Python bindings properly
bindings/python/wscript
--- a/bindings/python/wscript	Sun Jul 10 13:20:34 2011 -0400
+++ b/bindings/python/wscript	Mon Jul 11 14:24:59 2011 +0100
@@ -22,6 +22,8 @@
 
 from TaskGen import feature, after
 import Task, ccroot
+from python import _get_python_variables # this comes from wafadmin/Tools/python.py
+
 
 @feature('pch')
 @after('apply_link')
@@ -113,6 +115,19 @@
         conf.report_optional_feature("python", "Python Bindings", False, str(ex))
         return
 
+
+    # alternative code to computing PYTHONDIR, that is more correct than the one in waf 1.5.16
+    if 'PYTHONDIR' in conf.environ:
+        pydir = conf.environ['PYTHONDIR']
+    else:
+        (pydir,) = _get_python_variables(conf.env['PYTHON'],
+                                         ["get_python_lib(standard_lib=0, prefix=%r)" % conf.env['PREFIX']],
+                                         ['from distutils.sysconfig import get_python_lib'])
+    if hasattr(conf, 'define'): # conf.define is added by the C tool, so may not exist
+        conf.define('PYTHONDIR', pydir)
+    conf.env['PYTHONDIR'] = pydir
+
+
     # -fvisibility=hidden optimization
     if (conf.env['CXX_NAME'] == 'gcc' and [int(x) for x in conf.env['CC_VERSION']] >= [4,0,0]
         and conf.check_compilation_flag('-fvisibility=hidden')):