Index: /trunk/src/VBox/Installer/common/vboxapisetup.py
===================================================================
--- /trunk/src/VBox/Installer/common/vboxapisetup.py	(revision 54683)
+++ /trunk/src/VBox/Installer/common/vboxapisetup.py	(revision 54684)
@@ -1,4 +1,4 @@
 """
-Copyright (C) 2009-2012 Oracle Corporation
+Copyright (C) 2009-2015 Oracle Corporation
 
 This file is part of VirtualBox Open Source Edition (OSE), as
@@ -17,5 +17,5 @@
     import shutil
     from distutils.sysconfig import get_python_lib
-    comCache1 = os.path.join(get_python_lib(),'win32com', 'gen_py')
+    comCache1 = os.path.join(get_python_lib(), 'win32com', 'gen_py')
     comCache2 = os.path.join(os.environ.get("TEMP", "c:\\tmp"), 'gen_py')
     print "Cleaning COM cache at",comCache1,"and",comCache2
@@ -24,5 +24,5 @@
 
 def patchWith(file,install,sdk):
-    newFile=file+".new"
+    newFile=file + ".new"
     install=install.replace("\\", "\\\\")
     try:
@@ -33,6 +33,6 @@
     newF = open(newFile, 'w')
     for line in oldF:
-        line=line.replace("%VBOX_INSTALL_PATH%",install)
-        line=line.replace("%VBOX_SDK_PATH%",sdk)
+        line = line.replace("%VBOX_INSTALL_PATH%", install)
+        line = line.replace("%VBOX_SDK_PATH%", sdk)
         newF.write(line)
     newF.close()
@@ -46,31 +46,33 @@
 # See http://docs.python.org/distutils/index.html
 def main(argv):
-    vboxDest=os.environ.get("VBOX_INSTALL_PATH", None)
+    vboxDest = os.environ.get("VBOX_INSTALL_PATH", None)
     if vboxDest is None:
         raise Exception("No VBOX_INSTALL_PATH defined, exiting")
-    vboxVersion=os.environ.get("VBOX_VERSION", None)
+
+    vboxVersion = os.environ.get("VBOX_VERSION", None)
     if vboxVersion is None:
         # Should we use VBox version for binding module versioning?
         vboxVersion = "1.0"
+
     import platform
-    if platform.system() == 'Darwin':
-        vboxSdkDest = os.path.join(vboxDest, "..", "..", "..", "sdk")
-        if not os.path.isdir(vboxSdkDest):
-            vboxSdkDest = os.path.join(vboxDest, "sdk")
-    else:
-        vboxSdkDest = os.path.join(vboxDest, "sdk")
+
     if platform.system() == 'Windows':
         cleanupComCache()
-    patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
+
+    # Darwin: Patched before installation. Modifying bundle is not allowed, breaks signing and upsets gatekeeper.
+    if platform.system() != 'Darwin':
+        vboxSdkDest = os.path.join(vboxDest, "sdk")
+        patchWith(os.path.join(os.path.dirname(sys.argv[0]), 'vboxapi', '__init__.py'), vboxDest, vboxSdkDest)
+
     setup(name='vboxapi',
-      version=vboxVersion,
-      description='Python interface to VirtualBox',
-      author='Oracle Corp.',
-      author_email='vbox-dev@virtualbox.org',
-      url='http://www.virtualbox.org',
-      packages=['vboxapi']
-      )
-
+          version=vboxVersion,
+          description='Python interface to VirtualBox',
+          author='Oracle Corp.',
+          author_email='vbox-dev@virtualbox.org',
+          url='http://www.virtualbox.org',
+          packages=['vboxapi']
+          )
 
 if __name__ == '__main__':
     main(sys.argv)
+
Index: /trunk/src/VBox/Main/glue/vboxapi.py
===================================================================
--- /trunk/src/VBox/Main/glue/vboxapi.py	(revision 54683)
+++ /trunk/src/VBox/Main/glue/vboxapi.py	(revision 54684)
@@ -94,16 +94,21 @@
 # Globals, environment and sys.path changes.
 #
+import platform;
 VBoxBinDir = os.environ.get("VBOX_PROGRAM_PATH", None)
 VBoxSdkDir = os.environ.get("VBOX_SDK_PATH", None)
 
 if VBoxBinDir is None:
-    # Will be set by the installer
-    VBoxBinDir = "%VBOX_INSTALL_PATH%"
+    if platform.system() == 'Darwin':
+        VBoxBinDir = '/Applications/VirtualBox.app/Contents/MacOS'
+    else: # Will be set by the installer
+        VBoxBinDir = "%VBOX_INSTALL_PATH%"
 else:
     VBoxBinDir = os.path.abspath(VBoxBinDir)
 
 if VBoxSdkDir is None:
-    # Will be set by the installer
-    VBoxSdkDir = "%VBOX_SDK_PATH%"
+    if platform.system() == 'Darwin':
+        VBoxSdkDir = '/Applications/VirtualBox.app/Contents/MacOS/sdk'
+    else: # Will be set by the installer
+        VBoxSdkDir = "%VBOX_SDK_PATH%"
 else:
     VBoxSdkDir = os.path.abspath(VBoxSdkDir)
