[Python-checkins] python/dist/src/Lib/plat-mac bundlebuilder.py,1.26,1.27

jvr@users.sourceforge.net jvr@users.sourceforge.net
Fri, 20 Jun 2003 11:56:12 -0700


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv12462

Modified Files:
	bundlebuilder.py 
Log Message:
Add initial standalone support for Python.framework

Index: bundlebuilder.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bundlebuilder.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** bundlebuilder.py	25 May 2003 22:00:16 -0000	1.26
--- bundlebuilder.py	20 Jun 2003 18:56:10 -0000	1.27
***************
*** 285,288 ****
--- 285,289 ----
  os.environ["PYTHONEXECUTABLE"] = executable
  os.environ["DYLD_LIBRARY_PATH"] = libdir
+ os.environ["DYLD_FRAMEWORK_PATH"] = libdir
  os.execve(executable, sys.argv, os.environ)
  """
***************
*** 299,302 ****
--- 300,315 ----
  """
  
+ #
+ # When building a standalone app with Python.framework, we need to copy
+ # a subset from Python.framework to the bundle. The following list
+ # specifies exactly what items we'll copy.
+ #
+ PYTHONFRAMEWORKGOODIES = [
+     "Python",  # the Python core library
+     "Resources/English.lproj",
+     "Resources/Info.plist",
+     "Resources/version.plist",
+ ]
+ 
  
  class AppBuilder(BundleBuilder):
***************
*** 332,339 ****
      # If True, build standalone app.
      standalone = 0
!     
      # If set, use this for #! lines in stead of sys.executable
      python = None
!     
      # If True, add a real main program that emulates sys.argv before calling
      # mainprogram
--- 345,352 ----
      # If True, build standalone app.
      standalone = 0
! 
      # If set, use this for #! lines in stead of sys.executable
      python = None
! 
      # If True, add a real main program that emulates sys.argv before calling
      # mainprogram
***************
*** 393,396 ****
--- 406,412 ----
                  self.plist.NSPrincipalClass = "NSApplication"
  
+         if self.standalone and "Python.framework" in sys.exec_prefix:
+             self.addPythonFramework()
+ 
          BundleBuilder.setup(self)
  
***************
*** 474,477 ****
--- 490,507 ----
          if self.missingModules or self.maybeMissingModules:
              self.reportMissing()
+ 
+     def addPythonFramework(self):
+         # If we're building a standalone app with Python.framework,
+         # include a minimal subset of Python.framework
+         frameworkpath = sys.exec_prefix[:sys.exec_prefix.find(
+             "Python.framework") + len("Python.framework")]
+         version = sys.version[:3]
+         frameworkpath = pathjoin(frameworkpath, "Versions", version)
+         destbase = pathjoin("Contents", "Frameworks", "Python.framework",
+                             "Versions", version)
+         for item in PYTHONFRAMEWORKGOODIES:
+             src = pathjoin(frameworkpath, item)
+             dst = pathjoin(destbase, item)
+             self.files.append((src, dst))
  
      def addPythonModules(self):