WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Merged.

Use the auxbin module to find the appropriate install directory for our Python

# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID d61fc1f33954b70e61fc4b086aed50f499fcf8b9
# Parent  3534801f08da20eb302285d888162542bebe12b1
Use the auxbin module to find the appropriate install directory for our Python
scripts.

This fixes a bug with xm-test not working on 64-bit systems.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/misc/xend                         |   24 ++++++++++++++++++++----
 tools/python/xen/util/auxbin.py         |   19 ++++++++++++-------
 tools/xm-test/configure.ac              |    2 +-
 tools/xm-test/lib/XmTestLib/__init__.py |   20 +++++++++++++++++---
 4 files changed, 50 insertions(+), 15 deletions(-)

diff -r 3534801f08da -r d61fc1f33954 tools/misc/xend
--- a/tools/misc/xend   Fri May 05 16:46:48 2006 +0100
+++ b/tools/misc/xend   Fri May 05 18:36:12 2006 +0100
@@ -2,7 +2,7 @@
 #  -*- mode: python; -*-
 #============================================================================
 # Copyright (C) 2004 Mike Wray <mike.wray@xxxxxx>
-# Copyright (C) 2005 XenSource Ltd
+# Copyright (C) 2005-2006 XenSource Inc
 #============================================================================
 
 """Xen management daemon.
@@ -21,15 +21,31 @@
    and recover its state when restarted.
 """
 import os
+import os.path
 import sys
 import socket
 import signal
 import time
 import commands
 
-# add fallback path for non-native python path installs if needed
-sys.path.append('/usr/lib/python')
-sys.path.append('/usr/lib64/python')
+
+# Use the auxbin module in Xend to determine the correct Python path.  We
+# take the first installed instance of auxbin that we find, and then run it
+# to determine the correct path, appending that to sys.path.
+
+AUXBIN = 'xen/util/auxbin.py'
+
+for p in ['python%s' % sys.version[:3], 'python']:
+    for l in ['/usr/lib64', '/usr/lib']:
+        d = os.path.join(l, p)
+        if os.path.exists(os.path.join(d, AUXBIN)):
+            sys.path.append(d)
+            import xen.util.auxbin
+            libpath = xen.util.auxbin.libpath()
+            sys.path = sys.path[:-1]
+            sys.path.append(libpath)
+            break
+
 from xen.xend.server import SrvDaemon
 
 class CheckError(ValueError):
diff -r 3534801f08da -r d61fc1f33954 tools/python/xen/util/auxbin.py
--- a/tools/python/xen/util/auxbin.py   Fri May 05 16:46:48 2006 +0100
+++ b/tools/python/xen/util/auxbin.py   Fri May 05 18:36:12 2006 +0100
@@ -12,14 +12,15 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #============================================================================
-# Copyright (C) 2005 XenSource Ltd
+# Copyright (C) 2005-2006 XenSource Inc.
 #============================================================================
 
 
-LIB_BIN_32 = "/usr/lib/xen/bin"
-LIB_BIN_64 = "/usr/lib64/xen/bin"
+LIB_32 = "/usr/lib"
+LIB_64 = "/usr/lib64"
+LIB_BIN_SUFFIX = "xen/bin"
 
-## The architectures on which the LIB_BIN_64 directory is used.  This
+## The architectures on which the LIB_64 directory is used.  This
 # deliberately excludes ia64.
 LIB_64_ARCHS = [ 'x86_64', 'ppc64', 's390x', 'sparc64']
 
@@ -41,8 +42,12 @@ def pathTo(exe):
 
 
 def path():
+    return os.path.join(libpath(), LIB_BIN_SUFFIX)
+
+
+def libpath():
     machine = os.uname()[4]
-    if machine in LIB_64_ARCHS and os.path.exists(LIB_BIN_64):
-        return LIB_BIN_64
+    if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
+        return LIB_64
     else:
-        return LIB_BIN_32
+        return LIB_32
diff -r 3534801f08da -r d61fc1f33954 tools/xm-test/configure.ac
--- a/tools/xm-test/configure.ac        Fri May 05 16:46:48 2006 +0100
+++ b/tools/xm-test/configure.ac        Fri May 05 18:36:12 2006 +0100
@@ -13,7 +13,7 @@ AC_CHECK_PROG([LILO], lilo,   lilo,   "no",   
 # are two levels above the tests
 TESTLIB=../../lib
 RD_PATH=../../ramdisk
-TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB:/usr/lib/python RD_PATH=$RD_PATH"
+TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB RD_PATH=$RD_PATH"
 
 AC_ARG_ENABLE(hvm-support,
        [[  --enable-hvm-support           enable hardware virtual machine 
assist]],
diff -r 3534801f08da -r d61fc1f33954 tools/xm-test/lib/XmTestLib/__init__.py
--- a/tools/xm-test/lib/XmTestLib/__init__.py   Fri May 05 16:46:48 2006 +0100
+++ b/tools/xm-test/lib/XmTestLib/__init__.py   Fri May 05 18:36:12 2006 +0100
@@ -11,11 +11,25 @@ from XenDevice import *
 from XenDevice import *
 from NetConfig import *
 
-# Make sure xen modules are in path
-sys.path.append('/usr/lib/python')
+# Use the auxbin module in Xend to determine the correct Python path.  We
+# take the first installed instance of auxbin that we find, and then run it
+# to determine the correct path, appending that to sys.path.
+
+AUXBIN = 'xen/util/auxbin.py'
+
+for p in ['python%s' % sys.version[:3], 'python']:
+    for l in ['/usr/lib64', '/usr/lib']:
+        d = os.path.join(l, p)
+        if os.path.exists(os.path.join(d, AUXBIN)):
+            sys.path.append(d)
+            import xen.util.auxbin
+            libpath = xen.util.auxbin.libpath()
+            sys.path = sys.path[:-1]
+            sys.path.append(libpath)
+            break
 
 # Give this test a clean slate
-destroyAllDomUs();
+destroyAllDomUs()
 
 if os.environ.get("TEST_VERBOSE"):
     verbose = True

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>