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 | #============================================================================ |
---|
19 | |
---|
20 | |
---|
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. |
---|
24 | |
---|
25 | AUXBIN = 'xen/util/auxbin.py' |
---|
26 | |
---|
27 | import os |
---|
28 | import os.path |
---|
29 | import sys |
---|
30 | |
---|
31 | for p in ['python%s' % sys.version[:3], 'python']: |
---|
32 | for l in ['/usr/lib64', '/usr/lib']: |
---|
33 | d = os.path.join(l, p) |
---|
34 | if os.path.exists(os.path.join(d, AUXBIN)): |
---|
35 | sys.path.append(d) |
---|
36 | import xen.util.auxbin |
---|
37 | print os.path.join(xen.util.auxbin.libpath(), p) |
---|
38 | sys.exit(0) |
---|
39 | |
---|
40 | print >>sys.stderr, "Cannot find Xen Python modules." |
---|
41 | sys.exit(1) |
---|