Commits

b...@redivi.com  committed 81fa3d3

EggInstaller example

  • Participants
  • Parent commits 3d5b6d8
  • Tags py2app-0.3.1

Comments (0)

Files changed (9)

+py2app 0.3.1
+------------
+
+py2app 0.3.1 is a minor bugfix release.
+
+Functional changes:
+
+- New EggInstaller example
+
+Bug Fixes:
+
+- Now ensures that the executable is +x (when installed from egg this may not
+  be the case)
+
+
 py2app 0.3.0
 ------------
 

File examples/EggInstaller/Egg.icns

Binary file added.

File examples/EggInstaller/EggInstaller.py

+import os
+import sys
+import time
+import tempfile
+
+SCRIPT = """#!%s
+import os
+import sys
+if os.getuid() and os.geteuid():
+    print '''
+***
+
+easy_install may need root permission, re-executing under sudo.
+You may need to enter your password at the prompt below.
+
+***
+'''
+    cmd = ['/usr/bin/sudo', sys.executable] + sys.argv
+    os.execv(cmd[0], cmd)
+os.unlink(sys.argv[0])
+sys.argv[1:] = %r
+print ''
+print '$ easy_install ' + ' '.join(sys.argv[1:])
+if __name__ == '__main__':
+    from setuptools.command.easy_install import main
+    main()
+"""
+
+def log(*args):
+    print '[EggInstaller]', ' '.join(map(str, args))
+
+def main():
+    fd, name = tempfile.mkstemp(suffix='.py', prefix='EggInstaller')
+    script = os.fdopen(fd, 'w+b')
+    script.write(SCRIPT % (sys.executable, ['--'] + sys.argv[1:]))
+    script.flush()
+    script.close()
+    os.chmod(name, 0700)
+    cmd = ['/usr/bin/open', '-a', 'Terminal', name]
+    os.spawnv(os.P_WAIT, cmd[0], cmd)
+    log('waiting for', name)
+    while os.path.exists(name):
+        time.sleep(0.1)
+    log('done')
+    
+if __name__ == '__main__':
+    main()

File examples/EggInstaller/setup.py

+"""
+Script for building the example.
+
+Usage:
+    python setup.py py2app
+"""
+from setuptools import setup
+
+PLIST = dict(
+    CFBundleIdentifier='org.pythonmac.py2app.EggInstaller',
+    CFBundleDocumentTypes=[
+        dict(
+            CFBundleTypeExtensions=['egg'],
+            CFBundleTypeIconFile='Egg.icns',
+            CFBundleTypeRole='Shell',
+        )
+    ],
+)
+
+setup(
+    setup_requires=["py2app"],
+    app=["EggInstaller.py"],
+    options=dict(py2app=dict(
+        semi_standalone=True,
+        site_packages=True,
+        argv_emulation=True,
+        iconfile='Egg.icns',
+        plist=PLIST,
+    ))
+)

File py2app/__init__.py

                 if a directory is contained, must be the same for all targets
 """
 
-__version__ = "0.3"
+__version__ = "0.3.1"
 import py2app.install

File py2app/create_appbundle.py

 # XXX - plugins, prefpane, etc?
 from pkg_resources import resource_filename
 import py2app.apptemplate
-from py2app.util import makedirs, mergecopy, mergetree, skipscm
+from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec
 
 def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate,
         platform='MacOS', copy=mergecopy, mergetree=mergetree,
         kw['CFBundlePackageType'] + kw['CFBundleSignature']
     )
     copy(srcmain, destmain)
+    make_exec(destmain)
     mergetree(
         resource_filename(module.__name__, 'lib'),
         resources,

File py2app/create_pluginbundle.py

 from pkg_resources import resource_filename
 
 import py2app.bundletemplate
-from py2app.util import makedirs, mergecopy, mergetree, skipscm
+from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec
 
 def create_pluginbundle(destdir, name, extension='.plugin', module=py2app.bundletemplate,
         platform='MacOS', copy=mergecopy, mergetree=mergetree,
         kw['CFBundlePackageType'] + kw['CFBundleSignature']
     )
     copy(srcmain, destmain)
+    make_exec(destmain)
     mergetree(
         resource_filename(module.__name__, 'lib'),
         resources,

File py2app/util.py

 def fsencoding(s, encoding=sys.getfilesystemencoding()):
     return macholib.util.fsencoding(s, encoding=encoding)
 
+def make_exec(path):
+    mask = os.umask(0)
+    os.umask(mask)
+    os.chmod(path, os.stat(path).st_mode | (0111 & ~mask))
+
 def makedirs(path):
     path = fsencoding(path)
     if not os.path.exists(path):
 setup(
     # metadata
     name='py2app',
-    version='0.3',
+    version='0.3.1',
     description='distutils command for creating Mac OS X applications',
     author='Bob Ippolito',
     author_email='bob@redivi.com',