wafsamba: Eliminate sys.path updating if installing to a standard python
authorJelmer Vernooij <jelmer@samba.org>
Wed, 8 Sep 2010 20:45:12 +0000 (22:45 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 8 Sep 2010 20:52:43 +0000 (22:52 +0200)
path.

buildtools/wafsamba/wafsamba.py

index 50d0df24a09a17a6aec68affb2e238afaa6eed62..11de9d5dccb2d5b37dfacc4b7bb7100bd633b79b 100644 (file)
@@ -594,8 +594,14 @@ def install_file(bld, destdir, file, chmod=0644, flat=False,
     if python_fixup:
         # fixup the python path it will use to find Samba modules
         inst_file = file + '.inst'
+        if bld.env["PYTHONDIR"] not in sys.path:
+            regex = "s|\(sys.path.insert.*\)bin/python\(.*\)$|\\1${PYTHONDIR}\\2|g"
+        else:
+            # Eliminate updating sys.path if the target python dir is already
+            # in python path.
+            regex = "s|sys.path.insert.*bin/python.*$||g"
         bld.SAMBA_GENERATOR('python_%s' % destname,
-                            rule="sed 's|\(sys.path.insert.*\)bin/python\(.*\)$|\\1${PYTHONDIR}\\2|g' < ${SRC} > ${TGT}",
+                            rule="sed '%s' < ${SRC} > ${TGT}" % regex,
                             source=file,
                             target=inst_file)
         file = inst_file