Commits

Anonymous committed 1a800b1

some Mac OS X specific fixes

  • Participants
  • Parent commits a879657

Comments (0)

Files changed (5)

File examples/macosx/aliens_app_example/aliens_bootstrap.py

 class PygameAppDelegate(NibClassBuilder.AutoBaseClass):
     def applicationDidFinishLaunching_(self, aNotification):
         try:
-            import pkgdata_nsbundle
-            import os
-            os.chdir(NSBundle.mainBundle().resourcePath())
             import aliens
             aliens.main()
         except:

File examples/macosx/aliens_app_example/buildapp.py

-from bundlebuilder2 import buildapp
-from plistlib import Plist, Dict
-import glob, imp, shutil, os
-
-NAME = 'aliens'
-VERSION = '0.1'
-
-infoPlist = Plist(
-    CFBundleIconFile            = NAME,
-    CFBundleName                = NAME,
-    CFBundleShortVersionString  = VERSION,
-    CFBundleGetInfoString       = ' '.join([NAME, VERSION]),
-    CFBundleExecutable          = NAME,
-)
-
-# pkgdata stuff
-pygamedata = os.path.join('pkgdata', 'pygame')
-if not os.path.exists(pygamedata):
-    os.makedirs(pygamedata)
-    pygamedir = imp.find_module('pygame')[1]
-    for fn in glob.glob(os.path.join(pygamedir, '*.ttf')):
-        shutil.copy(fn, pygamedata)
-
-buildapp(
-    name        = NAME,
-    bundle_id   = 'org.pygame.aliens',
-    mainprogram = 'aliens_bootstrap.py',
-    nibname     = 'MainMenu',
-    resources   = ["English.lproj", "../../data", "pkgdata"],
-    plist       = infoPlist,
-)

File examples/macosx/aliens_app_example/pkgdata_nsbundle.py

-#
-# This is a Mac OS X / PyObjC / Bundlebuilder extension for pkgdata.
-#
-# data files are located in the resources folder as such:
-#   %(appName)s/Contents/Resources/pkgdata/%(pkgname)s/%(identifier)s
-#   
-
-import os
-from protocols import declareAdapter, protocolForURI
-from Foundation import NSBundle
-
-__apiversion__ = '0'
-BASEURI = 'org.undefined.pkgdata.' + __apiversion__
-
-def localProtocol(s):
-    return protocolForURI(BASEURI + '.' + s)
-
-IPackageFileTuple = localProtocol('packagefiletuple')
-IReadableFileLike = localProtocol('readablefilelike')
-IReadableFilePath = localProtocol('readablefilepath')
-
-def pathForPackageFileTuple(pkgtuple, protocol):
-    bndl = NSBundle.mainBundle()
-    if bndl is None:
-        raise IOError(2, 'No main bundle')
-    pkgname, identifier = pkgtuple
-    pkgname = '.'.join(pkgname.split('.')[:-1])
-    dataPath = os.path.join(
-        bndl.resourcePath(), 'pkgdata', pkgname, identifier
-    )
-    if not os.path.exists(dataPath):
-        raise IOError(2, 'No such file or directory', dataPath)
-    return dataPath
-declareAdapter(
-    pathForPackageFileTuple,
-    provides=[IReadableFilePath],
-    forProtocols=[IPackageFileTuple],
-)
-
-
-def openFilePath(path, protocol):
-    return file(path, mode='rb')
-declareAdapter(
-    openFilePath,
-    provides=[IReadableFileLike],
-    forProtocols=[IReadableFilePath],
-)

File examples/macosx/aliens_app_example/setup.py

+"""
+Script for building the example.
+
+Usage:
+    python setup.py py2app
+"""
+from distutils.core import setup
+import py2app
+
+NAME = 'aliens'
+VERSION = '0.1'
+
+plist = dict(
+    CFBundleIconFile=NAME,
+    CFBundleName=NAME,
+    CFBundleShortVersionString=VERSION,
+    CFBundleGetInfoString=' '.join([NAME, VERSION]),
+    CFBundleExecutable=NAME,
+    CFBundleIdentifier='org.pygame.examples.aliens',
+)
+
+setup(
+    data_files=['English.lproj', '../../data'],
+    app=[
+        dict(script="aliens_bootstrap.py", plist=plist),
+    ],
+)

File lib/__init__.py

 try: import pygame.mixer_music; del pygame.mixer_music
 except (ImportError,IOError):pass
 
+def packager_imports():
+    """
+    Some additional things that py2app/py2exe will want to see
+    """
+    import pygame.macosx
+    import Numeric
+    import OpenGL.GL
 
 #make Rects pickleable
 import copy_reg