install.py

changeset 1387
1734bc5f4f82
parent 1385
9eaf0cda4fb4
child 1388
deb3a1940126
--- a/install.py	Sat Oct 22 19:54:49 2011 +0200
+++ b/install.py	Sun Oct 23 14:15:17 2011 +0200
@@ -324,13 +324,14 @@
             
         # Cleanup the install directories
         for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir',
-                     'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',
-                     'ericOthersDir', 'ericStylesDir', 'ericDir']:
+                     'ericIconDir', 'ericPixDir', 'ericTemplatesDir',
+                     'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir']:
             if os.path.exists(getConfig(name)):
                 shutil.rmtree(getConfig(name), True)
         
         # Cleanup translations
-        for name in glob.glob(os.path.join(getConfig('ericTranslationsDir'), 'eric5_*.qm')):
+        for name in glob.glob(
+                os.path.join(getConfig('ericTranslationsDir'), 'eric5_*.qm')):
             if os.path.exists(name):
                 os.remove(name)
         
@@ -342,11 +343,17 @@
                     apiname = os.path.join(apidir, progLanguage.lower(), name)
                     if os.path.exists(apiname):
                         os.remove(apiname)
-                for apiname in glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")):
+                for apiname in glob.glob(
+                        os.path.join(apidir, progLanguage.lower(), "*.bas")):
                     os.remove(apiname)
         except AttributeError:
             pass
         
+        if sys.platform == "darwin":
+            # delete the Mac app bundle
+            if os.path.exists("/Developer/Applications/Eric5"):
+                shutil.rmtree("/Developer/Applications/Eric5")
+        
     except IOError as msg:
         sys.stderr.write('IOError: {0}\nTry install with admin rights.\n'.format(msg))
         exit(7)
@@ -520,6 +527,52 @@
                 "/usr/share/pixmaps")
             shutil.copy(os.path.join(sourceDir, "eric5.desktop"),
                 "/usr/share/applications")
+    
+    if sys.platform == "darwin":
+        createMacAppBundle()
+
+
+def createMacAppBundle():
+    """
+    Create a Mac application bundle.
+    """
+    global cfg, sourceDir
+    
+    dirs = {"contents": "/Developer/Applications/Eric5/eric5.app/Contents/",
+            "exe": "/Developer/Applications/Eric5/eric5.app/Contents/MacOS",
+            "icns": "/Developer/Applications/Eric5/eric5.app/Contents/Resources"}
+    os.makedirs(dirs["contents"])
+    os.mkdir(dirs["exe"])
+    os.mkdir(dirs["icns"])
+    shutil.copy(os.path.join(cfg['bindir'], "eric5"), dirs["exe"])
+    shutil.copy(os.path.join(sourceDir, "pixmaps", "eric_1.icns"),
+                os.path.join(dirs["icns"], "eric.icns"))
+    f = open(os.path.join(dirs["contents"], "Info.plist"), "wb")
+    f.write(\
+'''<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
+          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>CFBundleExecutable</key>
+    <string>eric5</string>
+    <key>CFBundleIconFile</key>
+    <string>eric.icns</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>1.0</string>
+    <key>CFBundleName</key>
+    <string>eric5</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>1.0</string>
+</dict>
+</plist>
+'''        
+    )
+    f.close()
 
 
 def createInstallConfig():

eric ide

mercurial