From: Jeremy Katz Subject: [PATCH] Make non-native python path handling a fallback Date: Fri, 15 Apr 2005 16:36:56 -0400 Message-ID: <1113597416.4379.21.camel@bree.local.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-nJxqONtADpxd25pTBMLQ" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --=-nJxqONtADpxd25pTBMLQ Content-Type: text/plain Content-Transfer-Encoding: 7bit Although I don't really agree with the installing of the python bits to the non-native paths, I can see where it's useful as long as the module ABI doesn't change if you're trying to distribute binary tarballs. But with the current handling it adds module lookup costs for the native path case (which would be the norm) as well as prevents using PYTHONPATH to look to a different location for the modules. The attached patch changes things so that at first, the xen module is attempted to be imported from the stock paths. If we get an ImportError exception, then it adds /usr/lib/python to the end of the python path and imports again. Signed-off-by: Jeremy Katz Jeremy --=-nJxqONtADpxd25pTBMLQ Content-Disposition: attachment; filename=xen-python-paths.patch Content-Type: text/x-patch; name=xen-python-paths.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit ===== tools/misc/netfix 1.13 vs edited ===== --- 1.13/tools/misc/netfix 2005-01-12 04:36:09 -05:00 +++ edited/tools/misc/netfix 2005-04-15 16:30:34 -04:00 @@ -9,9 +9,12 @@ from getopt import getopt -# Default install path for Xen binary packages. -sys.path = [ '/usr/lib/python' ] + sys.path -from xen.util.Brctl import * +# add fallback path for non-native python path installs if needed +try: + from xen.util.Brctl import * +except ImportError: + sys.path.append('/usr/lib/python') + from xen.util.Brctl import * short_options = 'hvqni:b:c' long_options = ['help', 'verbose', 'quiet', ===== tools/misc/xend 1.20 vs edited ===== --- 1.20/tools/misc/xend 2005-03-15 14:21:14 -05:00 +++ edited/tools/misc/xend 2005-04-15 16:30:04 -04:00 @@ -30,9 +30,12 @@ XCS_PIDFILE = "/var/run/xcs.pid" XCS_ARGS = (XCS_EXEC, "-p", XCS_PIDFILE) -# Default install path for Xen binary packages. -sys.path = [ '/usr/lib/python' ] + sys.path -from xen.xend.server import SrvDaemon +# add fallback path for non-native python path installs if needed +try: + from xen.xend.server import SrvDaemon +except ImportError: + sys.path.append('/usr/lib/python') + from xen.xend.server import SrvDaemon class CheckError(ValueError): pass ===== tools/misc/xensv 1.4 vs edited ===== --- 1.4/tools/misc/xensv 2005-01-12 04:36:09 -05:00 +++ edited/tools/misc/xensv 2005-04-15 16:30:06 -04:00 @@ -22,9 +22,12 @@ import sys import re -# Default install path for Xen binary packages. -sys.path = [ '/usr/lib/python' ] + sys.path -from xen.xend.server.params import XEND_PID_FILE +# add fallback path for non-native python path installs if needed +try: + from xen.xend.server.params import XEND_PID_FILE +except ImportError: + sys.path.append('/usr/lib/python') + from xen.xend.server.params import XEND_PID_FILE class CheckError(ValueError): pass ===== tools/misc/xm 1.9 vs edited ===== --- 1.9/tools/misc/xm 2005-01-12 04:36:09 -05:00 +++ edited/tools/misc/xm 2005-04-15 16:30:58 -04:00 @@ -2,8 +2,11 @@ # -*- mode: python; -*- import sys -# Default install path for Xen binary packages. -sys.path = [ '/usr/lib/python' ] + sys.path -from xen.xm import main +# add fallback path for non-native python path installs if needed +try: + from xen.xm import main +except ImportError: + sys.path.append('/usr/lib/python') + from xen.xm import main main.main(sys.argv) --=-nJxqONtADpxd25pTBMLQ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-nJxqONtADpxd25pTBMLQ--