Fix search pathes in python code
PATCH 1/1 Fix search pathes in python code
Hi,
Attached patch gets rid of hardcoded search pathes in python code.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
tools/python/Makefile +11 -2
@@ -13,9 +13,18 @@ POTFILE := $(PODIR)/xen-xm.pot I18NSRCFILES = $(shell find xen/xm/ -name '*.py') CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS)) NLSDIR = $(SHAREDIR)/locale +xenpath = "xen/util/path.py" -.PHONY: build buildpy -buildpy: +.PHONY: build buildpy genpath +genpath: + rm -f ${xenpath} + echo "SBINDIR=\"$(SBINDIR)\"" >> ${xenpath} + echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath} + echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath} + echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath} + echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath} + +buildpy: genpath CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build build: buildpy refresh-pot refresh-po $(CATALOGS)
tools/python/xen/util/auxbin.py +10 -29
@@ -16,19 +16,10 @@ #============================================================================ -LIB_32 = "/usr/lib" -LIB_64 = "/usr/lib64" -LIB_BIN_SUFFIX = "xen/bin" - -## The architectures on which the LIB_64 directory is used. This -# deliberately excludes ia64 and ppc64, and Solaris. -LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64'] - - import os import os.path import sys - +from xen.util.path import SBINDIR,BINDIR,LIBEXEC,LIBDIR,PRIVATE_BINDIR def execute(exe, args = None): exepath = pathTo(exe)
@@ -41,26 +32,16 @@ def execute(exe, args = None): print exepath, ": ", exn sys.exit(1) - -def pathTo(exe): - return os.path.join(path(), exe) - +SEARCHDIRS = [ BINDIR, SBINDIR, LIBEXEC, PRIVATE_BINDIR ] +def pathTo(exebin): + for dir in SEARCHDIRS: + exe = os.path.join(dir, exebin) + if os.path.exists(exe): + return exe + return None def path(): - return os.path.join(libpath(), LIB_BIN_SUFFIX) - + return LIBEXEC def libpath(): - machine = os.uname()[4] - if sys.argv[0] != '-c': - prefix = os.path.dirname(os.path.dirname(sys.argv[0])) - path = os.path.join(prefix, os.path.basename(LIB_64)) - if machine in LIB_64_ARCHS and os.path.exists(path): - return path - path = os.path.join(prefix, os.path.basename(LIB_32)) - if os.path.exists(path): - return path - if machine in LIB_64_ARCHS and os.path.exists(LIB_64): - return LIB_64 - else: - return LIB_32 + return LIBDIR
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Christoph Egger writes ("[Xen-devel] [PATCH] Fix search pathes in python code"):
Quoted 1 line
Attached patch gets rid of hardcoded search pathes in python code.
This is an interesting and useful thing to do in principle. What it actually does is have the build system write the installation paths into the python code. I think this is much more correct than the existing arrangements.
I haven't however tested this specific change :-). What platforms did you test it on, and with what build process ?
Ian.
Quoted 1 line · On Tuesday 21 April 2009 18:01:53 Ian Jackson wrote:
Christoph Egger writes ("[Xen-devel] [PATCH] Fix search pathes in python
code"):
Quoted 9 lines
Quoted 1 line
Attached patch gets rid of hardcoded search pathes in python code.
This is an interesting and useful thing to do in principle. What it actually does is have the build system write the installation paths into the python code. I think this is much more correct than the existing arrangements.
I haven't however tested this specific change :-). What platforms did you test it on,
NetBSD and Linux.
Quoted 1 line
and with what build process ?
in xen toplevel source directory run
gmake dist-tools
or
PREFIX="/usr/local" gmake dist-tools
Then have a look into dist/install, copy the files
to your test machine machine,
set LD_LIBRARY_PATH and PYTHONPATH
and see if things work - i.e. if "xm console <domain>" finds the xenconsole binary.
<side-note>
Once we use rpath, then setting LD_LIBRARY_PATH won't be necessary anymore.
</side-note>
Christoph
P.S.: I'm really wondering why Linux distributors don't send such patches. I think, they modify the xen build system to fit into their rpm's.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632