VirtualBox

Changeset 12207 in vbox for trunk/src/libs/xpcom18a4/python


Ignore:
Timestamp:
Sep 8, 2008 9:02:22 AM (16 years ago)
Author:
vboxsync
Message:
  • versioned loader
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/vboxxpcom.py

    r11905 r12207  
    2222# for binaries in the same place as platfom independent modules, while
    2323# rest of Python bindings expect _xpcom to be inside xpcom module
    24 # XXX: maybe implement per Python version module search
    25 #cglue = __import__('VBoxPython')
     24
     25candidates = ['VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
     26              'VBoxPython' + str(sys.version_info[0]),
     27              'VBoxPython']
    2628if platform.system() == 'Darwin':
    2729    # On Darwin (aka Mac OS X) we know exactly where things are in a normal
     
    3335    #      be to to sed the file during install and inject the VBOX_PATH_APP_PRIVATE_ARCH
    3436    #      and VBOX_PATH_SHARED_LIBS when these are set.
    35     saved_sys_path = sys.path;
    36     sys.path = [ '/Applications/VirtualBox.app/Contents/MacOS', ] + saved_sys_path
    37     mod = 'VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1])
    38     cglue = __import__(mod)
    39     sys.path = saved_sys_path   
    40 else:
    41     cglue = __import__('VBoxPython') 
     37    sys.path.append('/Applications/VirtualBox.app/Contents/MacOS')
     38
     39cglue = None
     40for m in candidates:
     41   try:
     42      cglue =  __import__(m)
     43      break
     44   except:
     45      pass
     46
     47if platform.system() == 'Darwin':
     48    sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS')
     49
     50if cglue == None:
     51    raise Exception, "Cannot find VBoxPython module"
     52
    4253sys.modules['xpcom._xpcom'] = cglue
    4354xpcom._xpcom = cglue
Note: See TracChangeset for help on using the changeset viewer.

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