[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Always use sane upstream (`native') python paths



Previously, by default we would install our python modules into
/usr/lib/python/xen, for example /usr/lib/python/xen/__init__.py.
Upstream python's standard install location (a) includes the Python
version number and (b) puts things in site-packages by default.

Our best conjecture for the reason for this was an attempt to make the
installs portable between different python versions.  However, that
doesn't work because compiled python modules (.pyc), and C python
extensions corresponding to one version of python, are not compatible
across different versions of python.

This is why upstream include the version number.

site-packages is the standard location for locally-installed packages
and is automatically included on the python search path.

In this change, we abandon our own unusual python path setup:

 * Invoke setup.py in an entirely standard manner.  We pass
   PREFIX and DESTDIR using the appropriate options provided by
   setup.py for those purposes (adding them to setup.py calls
   which were previously lacking them).

 * Since the installation locations are now on the standard
   python path, we no longer need to add anything to the path
   in any of our python utilities.  Therefore remove all that
   code from every python script.  (Many of these scripts
   unconditionally added /usr/lib/python and /usr/lib64/python which
   is wrong even in the old world.)

 * There is no longer any special `Xen python path'.  xen-python-path
   is no longer needed.  It is no longer called by anything in our
   tree.  However since out-of-tree callers may still invoke it, we
   retain it.  It now prints a fixed string referring to a directory
   which does not to exist; callers (who use it to augment their
   python path) will thus add a nonexistent directory to their python
   path which is harmless.

 * Remove various workarounds including use of setup.py --home
   (which is intended for something completely different).

 * Remove tests for the XEN_PYTHON_NATIVE_INSTALL build-time
   environment variable.  The new behaviour is the behaviour which we
   should have had if this variable had been set.  That is, it is now
   as if this variable was always set but also bugs in the resulting
   install have been fixed.

This should be a proper fix for the bug addressed by c/s 19515.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

diff -r 9f945f16bd02 Makefile
--- a/Makefile  Wed Apr 08 13:18:22 2009 +0100
+++ b/Makefile  Wed Apr 08 16:01:07 2009 +0100
@@ -188,11 +188,7 @@ help:
        @echo '  clean-tboot      - clean the tboot module if it exists'
        @echo
        @echo 'Environment:'
-       @echo '  XEN_PYTHON_NATIVE_INSTALL=y'
-       @echo '                   - native python install or dist'
-       @echo '                     install into prefix/lib/python<VERSION>'
-       @echo '                     instead of <PREFIX>/lib/python'
-       @echo '                     true if set to non-empty value, false 
otherwise'
+       @echo '  [ this documentation is sadly not complete ]'
 
 # Use this target with extreme care!
 .PHONY: uninstall
diff -r 9f945f16bd02 tools/misc/sxp-pretty
--- a/tools/misc/sxp-pretty     Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/sxp-pretty     Wed Apr 08 15:59:04 2009 +0100
@@ -23,14 +23,6 @@ import pprint
 import pprint
 import sys
 
-result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]),
-                                               'xen-python-path'))
-if result[0] != 0:
-    print >>sys.stderr, result[1]
-    sys.exit(1)
-
-sys.path.append(result[1])
-
 import xen.xend.sxp as sxp
 
 def main():
diff -r 9f945f16bd02 tools/misc/xen-bugtool
--- a/tools/misc/xen-bugtool    Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/xen-bugtool    Wed Apr 08 15:59:04 2009 +0100
@@ -6,9 +6,6 @@
 
 import sys
 
-sys.path.append('/usr/lib/python')
-sys.path.append('/usr/lib64/python')
-
 from xen.util import bugtool
 
 
diff -r 9f945f16bd02 tools/misc/xen-python-path
--- a/tools/misc/xen-python-path        Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/xen-python-path        Wed Apr 08 15:56:25 2009 +0100
@@ -17,31 +17,8 @@
 # Copyright (C) 2007 XenSource Inc.
 #============================================================================
 
+# Nowadays we install xen in the standard python site-packages
+# directories.  This script is still provided for the benefit of old
+# out-of-xen-tree callers.  It is deprecated and will be removed.
 
-# 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'
-
-import os
-import os.path
-import sys
-
-usr   = os.path.dirname(os.path.dirname(sys.argv[0]))
-list  = [ os.path.join(usr,'lib64') ]
-list += [ os.path.join(usr,'lib') ]
-list += ['/usr/lib64', '/usr/lib']
-
-for l in list:
-    for p in ['python%s' % sys.version[:3], 'python']:
-        for k in ['', 'site-packages/']:
-            d = os.path.join(l, p, k)
-            if os.path.exists(os.path.join(d, AUXBIN)):
-                sys.path.append(d)
-                import xen.util.auxbin
-                print os.path.join(xen.util.auxbin.libpath(), p)
-                sys.exit(0)
-
-print >>sys.stderr, "Cannot find Xen Python modules."
-sys.exit(1)
+print '/dev/enoent/xen/python-path'
diff -r 9f945f16bd02 tools/misc/xend
--- a/tools/misc/xend   Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/xend   Wed Apr 08 15:54:54 2009 +0100
@@ -32,14 +32,6 @@ import signal
 import signal
 import time
 import commands
-
-xpp = os.path.join(os.path.dirname(sys.argv[0]), 'xen-python-path')
-if os.path.exists(xpp):
-    result = commands.getstatusoutput(xpp)
-    if result[0] != 0:
-        print >>sys.stderr, result[1]
-        sys.exit(1)
-    sys.path.append(result[1])
 
 from xen.xend.server import SrvDaemon
 
diff -r 9f945f16bd02 tools/misc/xm
--- a/tools/misc/xm     Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/xm     Wed Apr 08 15:56:53 2009 +0100
@@ -2,9 +2,6 @@
 #  -*- mode: python; -*-
 import sys
 
-# add fallback path for non-native python path installs if needed
-sys.path.append('/usr/lib/python')
-sys.path.append('/usr/lib64/python')
 from xen.xm import main
 
 main.main(sys.argv)
diff -r 9f945f16bd02 tools/misc/xsview
--- a/tools/misc/xsview Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/misc/xsview Wed Apr 08 15:59:04 2009 +0100
@@ -2,8 +2,6 @@
 
 import sys
 
-sys.path.append('/usr/lib/python')
-sys.path.append('/usr/lib64/python')
 from xen.xsview import main
 
 main.main(sys.argv)
diff -r 9f945f16bd02 tools/pygrub/Makefile
--- a/tools/pygrub/Makefile     Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/pygrub/Makefile     Wed Apr 08 16:08:06 2009 +0100
@@ -9,15 +9,10 @@ build:
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
 
 .PHONY: install
-ifndef XEN_PYTHON_NATIVE_INSTALL
 install: all
-       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)" --home="$(PREFIX)" --prefix="" --force
+       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install \
+               --prefix="$(PREFIX)" --root="$(DESTDIR)" --force
        $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
-else
-install: all
-       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)"
-       $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
-endif
 
 .PHONY: clean
 clean:
diff -r 9f945f16bd02 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/pygrub/src/pygrub   Wed Apr 08 15:59:48 2009 +0100
@@ -20,8 +20,6 @@ import platform
 
 import curses, _curses, curses.wrapper, curses.textpad, curses.ascii
 import getopt
-
-sys.path = [ '/usr/lib/python', '/usr/lib64/python' ] + sys.path
 
 import fsimage
 import grub.GrubConf
diff -r 9f945f16bd02 tools/python/Makefile
--- a/tools/python/Makefile     Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/python/Makefile     Wed Apr 08 15:53:54 2009 +0100
@@ -54,13 +54,9 @@ refresh-po: $(POTFILE)
        $(MSGFMT) -c -o $@ $<
 
 .PHONY: install
-ifndef XEN_PYTHON_NATIVE_INSTALL
 install: install-messages install-dtd
-       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)" --home="$(PREFIX)" --prefix="" --force
-else
-install: install-messages install-dtd
-       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)" --force
-endif
+       CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install \
+               --prefix="$(PREFIX)" --root="$(DESTDIR)" --force
 
 install-dtd: all
        $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
diff -r 9f945f16bd02 tools/python/scripts/test_hvm_create.py
--- a/tools/python/scripts/test_hvm_create.py   Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/python/scripts/test_hvm_create.py   Wed Apr 08 16:00:12 2009 +0100
@@ -74,7 +74,6 @@ console_cfg = {
 
 import sys
 import time
-sys.path.append('/usr/lib/python')
 
 from xapi import connect, execute
 
diff -r 9f945f16bd02 tools/python/scripts/test_vm_create.py
--- a/tools/python/scripts/test_vm_create.py    Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/python/scripts/test_vm_create.py    Wed Apr 08 15:59:48 2009 +0100
@@ -93,7 +93,6 @@ console_cfg = {
 
 import sys
 import time
-sys.path.append('/usr/lib/python')
 
 from xapi import connect, execute
 
diff -r 9f945f16bd02 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/python/scripts/xapi.py      Wed Apr 08 15:59:48 2009 +0100
@@ -20,7 +20,6 @@ import time
 import time
 import re
 import os
-sys.path.append('/usr/lib/python')
 
 from xen.util.xmlrpclib2 import ServerProxy
 from optparse import *
diff -r 9f945f16bd02 tools/security/Makefile
--- a/tools/security/Makefile   Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/security/Makefile   Wed Apr 08 16:01:55 2009 +0100
@@ -40,9 +40,6 @@ all: build
 all: build
 
 .PHONY: install
-ifndef XEN_PYTHON_NATIVE_INSTALL
-install: LIBPATH=$(shell PYTHONPATH=../python/xen/util python -c "import 
auxbin; print auxbin.libpath()")
-endif
 install: all $(ACM_CONFIG_FILE)
        $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
        $(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)$(SBINDIR)
@@ -63,11 +60,8 @@ install: all $(ACM_CONFIG_FILE)
        $(INSTALL_DATA) $(ACM_INST_HTML) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
        $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
        $(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
-ifndef XEN_PYTHON_NATIVE_INSTALL
-       python python/setup.py install 
--install-lib="$(DESTDIR)$(LIBPATH)/python"
-else
-       python python/setup.py install --root="$(DESTDIR)"
-endif
+       python python/setup.py install \
+               --prefix="$(PREFIX)" --root="$(DESTDIR)" --force
 else
 .PHONY: all
 all:
diff -r 9f945f16bd02 tools/security/python/xensec_tools/acm_getlabel
--- a/tools/security/python/xensec_tools/acm_getlabel   Wed Apr 08 13:18:22 
2009 +0100
+++ b/tools/security/python/xensec_tools/acm_getlabel   Wed Apr 08 15:59:04 
2009 +0100
@@ -3,10 +3,6 @@ import sys
 import sys
 import traceback
 import getopt
-
-# add fallback path for non-native python path installs if needed
-sys.path.insert(-1, '/usr/lib/python')
-sys.path.insert(-1, '/usr/lib64/python')
 
 from xen.util.security import ACMError, err, get_ssid
 
diff -r 9f945f16bd02 tools/security/xensec_gen.py
--- a/tools/security/xensec_gen.py      Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/security/xensec_gen.py      Wed Apr 08 15:59:04 2009 +0100
@@ -17,10 +17,6 @@
 
 import sys
 
-# Add fallback path for non-native python path installs if needed
-sys.path.append( '/usr/lib/python' )
-sys.path.append( '/usr/lib64/python' )
-
 from xen.xensec_gen import main
 
 main.main( )
diff -r 9f945f16bd02 tools/sv/index.psp
--- a/tools/sv/index.psp        Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/sv/index.psp        Wed Apr 08 15:59:04 2009 +0100
@@ -1,6 +1,5 @@
 <%
 import sys
-sys.path.append( "/usr/lib/python" )
 
 debug = True and False
 
diff -r 9f945f16bd02 tools/vnet/scripts/vn
--- a/tools/vnet/scripts/vn     Wed Apr 08 13:18:22 2009 +0100
+++ b/tools/vnet/scripts/vn     Wed Apr 08 15:59:04 2009 +0100
@@ -26,9 +26,6 @@ import socket
 import socket
 import sys
 from getopt import getopt, GetoptError
-
-sys.path.append('/usr/lib/python')
-sys.path.append('/usr/lib64/python')
 
 from xen.xend import sxp
 from xen.xend.PrettyPrint import prettyprint
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.