ia64/xen-unstable

view tools/misc/xen-python-path @ 15215:21f1a7a7ea30

xend: Add site-packages into Python search path
Signed-off-by: S.Caglar Onur <caglar@pardus.org.tr>
author kfraser@localhost.localdomain
date Thu May 24 15:30:05 2007 +0100 (2007-05-24)
parents afb41f6bc30a
children 7825043607bc
line source
1 #!/usr/bin/env python
2 # -*- mode: python; -*-
3 #============================================================================
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #============================================================================
17 # Copyright (C) 2007 XenSource Inc.
18 #============================================================================
21 # Use the auxbin module in Xend to determine the correct Python path. We
22 # take the first installed instance of auxbin that we find, and then run it
23 # to determine the correct path, appending that to sys.path.
25 AUXBIN = 'xen/util/auxbin.py'
27 import os
28 import os.path
29 import sys
31 for p in ['python%s' % sys.version[:3], 'python']:
32 for l in ['/usr/lib64', '/usr/lib']:
33 for k in ['', 'site-packages/']:
34 d = os.path.join(l, p, k)
35 if os.path.exists(os.path.join(d, AUXBIN)):
36 sys.path.append(d)
37 import xen.util.auxbin
38 print os.path.join(xen.util.auxbin.libpath(), p)
39 sys.exit(0)
41 print >>sys.stderr, "Cannot find Xen Python modules."
42 sys.exit(1)