VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/vboxxpcom.py@ 44529

Last change on this file since 44529 was 44529, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1"""
2Copyright (C) 2008-2012 Oracle Corporation
3
4This file is part of VirtualBox Open Source Edition (OSE), as
5available from http://www.virtualbox.org. This file is free software;
6you can redistribute it and/or modify it under the terms of the GNU
7General Public License (GPL) as published by the Free Software
8Foundation, in version 2 as it comes in the "COPYING" file of the
9VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11"""
12
13import xpcom
14import sys
15import platform
16
17# this code overcomes somewhat unlucky feature of Python, where it searches
18# for binaries in the same place as platfom independent modules, while
19# rest of Python bindings expect _xpcom to be inside xpcom module
20
21candidates = ['VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
22 'VBoxPython' + str(sys.version_info[0]),
23 'VBoxPython']
24if platform.system() == 'Darwin':
25 # On Darwin (aka Mac OS X) we know exactly where things are in a normal
26 # VirtualBox installation. Also, there are two versions of python there
27 # (2.3.x and 2.5.x) depending on whether the os is striped or spotty, so
28 # we have to choose the right module to load.
29 #
30 # XXX: This needs to be adjusted for OSE builds. A more general solution would
31 # be to to sed the file during install and inject the VBOX_PATH_APP_PRIVATE_ARCH
32 # and VBOX_PATH_SHARED_LIBS when these are set.
33 sys.path.append('/Applications/VirtualBox.app/Contents/MacOS')
34
35cglue = None
36for m in candidates:
37 try:
38 cglue = __import__(m)
39 break
40 except:
41 pass
42
43if platform.system() == 'Darwin':
44 sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS')
45
46if cglue == None:
47 raise Exception, "Cannot find VBoxPython module"
48
49sys.modules['xpcom._xpcom'] = cglue
50xpcom._xpcom = cglue
51
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette