s4-python: Use sys.prefix rather than guessing prefix from current
authorJelmer Vernooij <jelmer@samba.org>
Sat, 19 Jun 2010 11:41:48 +0000 (13:41 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 19 Jun 2010 11:41:48 +0000 (13:41 +0200)
file path.

source4/scripting/python/samba/provision.py

index 7fa5dbbdd7e42cdf3dbea08fd1a9eb5385d25b73..bfa1b952d4a5c49e67293e384f8458b7e526f006 100644 (file)
@@ -64,14 +64,13 @@ __docformat__ = "restructuredText"
 
 def find_setup_dir():
     """Find the setup directory used by provision."""
-    dirname = os.path.dirname(__file__)
-    if "/site-packages/" in dirname:
-        prefix = "/".join(dirname[:dirname.index("/site-packages/")].split("/")[:-2])
-        for suffix in ["share/setup", "share/samba/setup", "setup"]:
-            ret = os.path.join(prefix, suffix)
-            if os.path.isdir(ret):
-                return ret
+    import sys
+    for suffix in ["share/setup", "share/samba/setup", "setup"]:
+        ret = os.path.join(sys.prefix, suffix)
+        if os.path.isdir(ret):
+            return ret
     # In source tree
+    dirname = os.path.dirname(__file__)
     ret = os.path.join(dirname, "../../../setup")
     if os.path.isdir(ret):
         return ret