from distutils.core import setup import py2app import os import sys import vanilla import defconAppKit UTIs = [ dict( UTTypeIdentifier = "org.unifiedfontobject.ufo", UTTypeReferenceURL = "http://unifiedfontobject.org", UTTypeDescription = "Unified Font Object", UTTypeIconFile = "defconAppKitUFOIcon.icns", UTTypeConformsTo = ["com.apple.package"], UTTypeTagSpecification = { "public.filename-extension" : ["ufo"] } ) ] plist = dict( # export types UTExportedTypeDeclarations = UTIs, # import types UTImportedTypeDeclarations = UTIs, # document types CFBundleDocumentTypes = [ dict( LSItemContentTypes = ["org.unifiedfontobject.ufo"], NSExportableTypes = ["org.unifiedfontobject.ufo"], CFBundleTypeName = "Unified Font Object", CFBundleTypeRole = "Editor", NSDocumentClass = "Area51Document", CFBundleTypeIconFile = "defconAppKitUFOIcon.icns", LSTypeIsPackage = True ), ], CFBundleIdentifier = "com.typesupply.Area51", LSMinimumSystemVersion = "10.5.2", CFBundleShortVersionString = "1.0.2", CFBundleVersion = "1.0.2", CFBundleIconFile = "appIcon.icns", NSHumanReadableCopyright = "Copyright 2009 Type Supply LLC. All rights reserved." ) dataFiles = [ "Resources/English.lproj", "Resources/appIcon.icns", "Resources/Area51 Manual.pdf", os.path.dirname(vanilla.__file__), ] resources = os.path.join(os.path.dirname(__file__), "Resources") for fileName in os.listdir(resources): if fileName.endswith(".png"): dataFiles.append("Resources/%s" % fileName) # gather the defconAppKit resources defconAppKitResources = defconAppKit.__file__ for i in range(3): defconAppKitResources = os.path.dirname(defconAppKitResources) defconAppKitResources = os.path.join(defconAppKitResources, "Resources") for fileName in os.listdir(defconAppKitResources): if fileName.endswith(".pdf") or fileName.endswith(".icns"): dataFiles.append(os.path.join(defconAppKitResources, fileName)) setup( data_files=dataFiles, app=[dict(script="Area51.py", plist=plist)] ) # fix the icon from plistlib import readPlist, writePlist path = os.path.join(os.path.dirname(__file__), "dist", "Area51.app", "Contents", "Info.plist") plist = readPlist(path) plist["CFBundleIconFile"] = "appIcon.icns" writePlist(plist, path) # make the DMG if "-A" not in sys.argv: appLocation = os.path.join(os.getcwd(), "dist", "Area51.app") dmgTemplatePath = os.path.join(os.getcwd(), "Area51.dmgCanvas") if os.path.exists(dmgTemplatePath): import subprocess dmgPath = os.path.join(os.getcwd(), "dist", "Area51.dmg") popen = subprocess.Popen(["dmgcanvas", "-t", dmgTemplatePath, "-o", dmgPath]) popen.wait()