Commits

Anonymous committed 1c5b54e

sync with Python tree, fix app docking bug

Comments (0)

Files changed (1)

pyobjc/MPCompat/bundlebuilder.py

 
     def _getDefaults(cls):
         defaults = {}
+        for base in cls.__bases__:
+            if hasattr(base, "_getDefaults"):
+                defaults.update(base._getDefaults())
         for name, value in cls.__dict__.items():
             if name[0] != "_" and not isinstance(value,
                     (function, classmethod)):
                 defaults[name] = deepcopy(value)
-        for base in cls.__bases__:
-            if hasattr(base, "_getDefaults"):
-                defaults.update(base._getDefaults())
         return defaults
     _getDefaults = classmethod(_getDefaults)
 
     # The creator code of the bundle.
     creator = None
 
+    # the CFBundleIdentifier (this is used for the preferences file name)
+    bundle_id = None
+
     # List of files that have to be copied to <bundle>/Contents/Resources.
     resources = []
 
             else:
                 self.creator = "????"
         plist.CFBundleSignature = self.creator
-        if not hasattr(plist, "CFBundleIdentifier"):
+        if self.bundle_id:
+            plist.CFBundleIdentifier = self.bundle_id
+        elif not hasattr(plist, "CFBundleIdentifier"):
             plist.CFBundleIdentifier = self.name
 
     def build(self):
 mainprogram = os.path.join(resdir, "%(mainprogram)s")
 
 sys.argv.insert(1, mainprogram)
-os.environ["PYTHONPATH"] = resdir
-if %(standalone)s:
-    os.environ["PYTHONHOME"] = resdir
+if %(standalone)s or %(semi_standalone)s:
+    os.environ["PYTHONPATH"] = resdir
+    if %(standalone)s:
+        os.environ["PYTHONHOME"] = resdir
+else:
+    pypath = os.getenv("PYTHONPATH", "")
+    if pypath:
+        pypath = ":" + pypath
+    os.environ["PYTHONPATH"] = resdir + pypath
 os.environ["PYTHONEXECUTABLE"] = executable
 os.environ["DYLD_LIBRARY_PATH"] = libdir
 os.environ["DYLD_FRAMEWORK_PATH"] = libdir
         if self.executable is None:
             if not self.standalone and not isFramework():
                 self.symlink_exec = 1
-            self.executable = sys.executable
+            if self.python:
+                self.executable = self.python
+            else:
+                self.executable = sys.executable
 
         if self.nibname:
             self.plist.NSMainNibFile = self.nibname
             else:
                 hashbang = os.path.realpath(sys.executable)
             standalone = self.standalone
+            semi_standalone = self.semi_standalone
             open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals())
             os.chmod(bootstrappath, 0775)
 
   -c, --creator=CCCC     4-char creator code (default: '????')
       --iconfile=FILE    filename of the icon (an .icns file) to be used
                          as the Finder icon
+      --bundle-id=ID     the CFBundleIdentifier, in reverse-dns format
+                         (eg. org.python.BuildApplet; this is used for
+                         the preferences file name)
   -l, --link             symlink files/folder instead of copying them
       --link-exec        symlink the executable instead of copying it
       --standalone       build a standalone application, which is fully
         "mainprogram=", "creator=", "nib=", "plist=", "link",
         "link-exec", "help", "verbose", "quiet", "argv", "standalone",
         "exclude=", "include=", "package=", "strip", "iconfile=",
-        "lib=", "python=", "semi-standalone")
+        "lib=", "python=", "semi-standalone", "bundle-id=")
 
     try:
         options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
             builder.argv_emulation = 1
         elif opt in ('-c', '--creator'):
             builder.creator = arg
+        elif opt == '--bundle-id':
+            builder.bundle_id = arg
         elif opt == '--iconfile':
             builder.iconfile = arg
         elif opt == "--lib":