Commits

rona...@mac.com  committed bc43400

Add preboot script that redirects the pkg_resources
egg cache from the user's home directory to a
per-application directory in ~/Library/Caches.

This is needed for two reasons:
1) The new location is corresponds to were
Apple would like you to cache temporary files

2) A per-application directory ensures that
two applications cannot interfere with
each other.

This is a (small) first step towards adding
proper egg support to py2app.

  • Participants
  • Parent commits 5c7eca1

Comments (0)

Files changed (2)

File py2app/bootstrap/setup_pkgresource.py

+def _setup_pkgresources():
+    import pkg_resources
+    import os, plistlib
+
+    pl = plistlib.readPlist(os.path.join(
+        os.path.dirname(os.getenv('RESOURCEPATH')), "Info.plist"))
+    appname = pl.get('CFBundleIdentifier')
+    if appname is None:
+        appname = pl['CFBundleDisplayName']
+    path = os.path.expanduser('~/Library/Caches/%s/python-eggs'%(appname,))
+    pkg_resources.set_extraction_path(path)
+
+_setup_pkgresources()

File py2app/build_app.py

         if self.site_packages or self.alias:
             prescripts.append('site_packages')
 
+        if self.style == 'app':
+            prescripts.append('setup_pkgresource')
+
         if self.argv_emulation and self.style == 'app':
             prescripts.append('argv_emulation')
             if u'CFBundleDocumentTypes' not in self.plist: