diff options
author | Ewan Mellor <ewan@xensource.com> | 2007-02-01 12:48:53 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2007-02-01 12:48:53 +0000 |
commit | a84714b11ccd74c59d1034cf709e14e05ace4601 (patch) | |
tree | 9c54d683a758188d0c734e2140124bb705303c38 /tools/misc/xen-python-path | |
parent | 73c92d7bb211dd3a8d1c5bb086a70a3232a73d43 (diff) | |
download | xen-a84714b11ccd74c59d1034cf709e14e05ace4601.tar.gz xen-a84714b11ccd74c59d1034cf709e14e05ace4601.tar.bz2 xen-a84714b11ccd74c59d1034cf709e14e05ace4601.zip |
Break out the Python path interrogation into a separate script. This has the
advantage that the temporary path manipulation cannot affect the main script,
and that it can be shared with other programs, such as xm-test.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/misc/xen-python-path')
-rw-r--r-- | tools/misc/xen-python-path | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/misc/xen-python-path b/tools/misc/xen-python-path new file mode 100644 index 0000000000..03c572b8ef --- /dev/null +++ b/tools/misc/xen-python-path @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- mode: python; -*- +#============================================================================ +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# 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) 2007 XenSource Inc. +#============================================================================ + + +# 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 + +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 + print os.path.join(xen.util.auxbin.libpath(), p) + sys.exit(0) + +print >>sys.stderr, "Cannot find Xen Python modules." +sys.exit(1) |