[3a39c2e] | 1 | """ |
---|
| 2 | This is a setup.py script partly generated by py2applet |
---|
| 3 | |
---|
| 4 | Usage: |
---|
| 5 | python setup.py py2app |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | NOTES: |
---|
| 9 | 12/01/2011: When seeing an error related to pytz.zoneinfo not being found, change the following line in py2app/recipes/matplotlib.py |
---|
| 10 | mf.import_hook('pytz.tzinfo', m, ['UTC']) |
---|
| 11 | 12/05/2011: Needs macholib >= 1.4.3 and py2app >= 0.6.4 to create a 64-bit app |
---|
| 12 | """ |
---|
| 13 | from setuptools import setup |
---|
| 14 | import periodictable.xsf |
---|
| 15 | import sas.dataloader.readers |
---|
| 16 | import os |
---|
| 17 | import string |
---|
| 18 | import local_config |
---|
| 19 | import pytz |
---|
| 20 | import sys |
---|
| 21 | import platform |
---|
| 22 | |
---|
[a8d882a] | 23 | from distutils.util import get_platform |
---|
| 24 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
---|
| 25 | platform = '%s-%s'%(get_platform(),sys.version[:3]) |
---|
| 26 | build_path = os.path.join(root, 'build','lib.'+platform) |
---|
| 27 | sys.path.insert(0, build_path) |
---|
| 28 | |
---|
[3a39c2e] | 29 | ICON = local_config.SetupIconFile_mac |
---|
| 30 | EXTENSIONS_LIST = [] |
---|
| 31 | DATA_FILES = [] |
---|
| 32 | RESOURCES_FILES = [] |
---|
| 33 | |
---|
| 34 | #Periodictable data file |
---|
| 35 | DATA_FILES = periodictable.data_files() |
---|
| 36 | #invariant and calculator help doc |
---|
| 37 | import sas.perspectives.fitting as fitting |
---|
| 38 | DATA_FILES += fitting.data_files() |
---|
| 39 | import sas.perspectives.calculator as calculator |
---|
| 40 | DATA_FILES += calculator.data_files() |
---|
| 41 | import sas.perspectives.invariant as invariant |
---|
| 42 | DATA_FILES += invariant.data_files() |
---|
| 43 | import sas.models as models |
---|
| 44 | DATA_FILES += models.data_files() |
---|
| 45 | import sas.guiframe as guiframe |
---|
| 46 | DATA_FILES += guiframe.data_files() |
---|
| 47 | |
---|
| 48 | #CANSAxml reader data files |
---|
[59b1b92] | 49 | RESOURCES_FILES.append(os.path.join(sas.dataloader.readers.get_data_path(),'defaults.json')) |
---|
[3a39c2e] | 50 | |
---|
| 51 | # Locate libxml2 library |
---|
| 52 | lib_locs = ['/usr/local/lib', '/usr/lib'] |
---|
| 53 | libxml_path = None |
---|
| 54 | for item in lib_locs: |
---|
| 55 | libxml_path_test = '%s/libxml2.2.dylib' % item |
---|
| 56 | if os.path.isfile(libxml_path_test): |
---|
| 57 | libxml_path = libxml_path_test |
---|
| 58 | if libxml_path == None: |
---|
| 59 | raise RuntimeError, "Could not find libxml2 on the system" |
---|
| 60 | |
---|
| 61 | APP = ['sasview.py'] |
---|
| 62 | DATA_FILES += ['images','test','media', 'custom_config.py', 'local_config.py', |
---|
| 63 | 'default_categories.json'] |
---|
| 64 | if os.path.isfile("BUILD_NUMBER"): |
---|
| 65 | DATA_FILES.append("BUILD_NUMBER") |
---|
[a8d882a] | 66 | |
---|
| 67 | # See if the documentation has been built, and if so include it. |
---|
| 68 | doc_path = os.path.join(build_path, "doc") |
---|
| 69 | if os.path.exists(doc_path): |
---|
| 70 | for dirpath, dirnames, filenames in os.walk(doc_path): |
---|
| 71 | for filename in filenames: |
---|
| 72 | sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path)) |
---|
[018582f] | 73 | DATA_FILES.append((sub_dir, [os.path.join(dirpath, filename)])) |
---|
[a8d882a] | 74 | else: |
---|
| 75 | raise Exception("You must first build the documentation before creating an installer.") |
---|
[3a39c2e] | 76 | |
---|
| 77 | # locate file extensions |
---|
| 78 | def find_extension(): |
---|
| 79 | """ |
---|
| 80 | Describe the extensions that can be read by the current application |
---|
| 81 | """ |
---|
| 82 | try: |
---|
| 83 | list = [] |
---|
| 84 | EXCEPTION_LIST = ['*', '.', ''] |
---|
| 85 | from sas.dataloader.loader import Loader |
---|
| 86 | wild_cards = Loader().get_wildcards() |
---|
| 87 | for item in wild_cards: |
---|
| 88 | #['All (*.*)|*.*'] |
---|
| 89 | file_type, ext = string.split(item, "|*.", 1) |
---|
| 90 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 91 | list.append(ext) |
---|
| 92 | except: |
---|
| 93 | pass |
---|
| 94 | try: |
---|
| 95 | file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1) |
---|
| 96 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 97 | list.append(ext) |
---|
| 98 | except: |
---|
| 99 | pass |
---|
| 100 | try: |
---|
| 101 | for item in local_config.PLUGINS_WLIST: |
---|
| 102 | file_type, ext = string.split(item, "|*.", 1) |
---|
| 103 | if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list: |
---|
| 104 | list.append(ext) |
---|
| 105 | except: |
---|
| 106 | pass |
---|
| 107 | |
---|
| 108 | return list |
---|
| 109 | |
---|
| 110 | EXTENSIONS_LIST = find_extension() |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST, |
---|
| 114 | CFBundleTypeIconFile=ICON, |
---|
| 115 | CFBundleTypeName="sasview file", |
---|
| 116 | CFBundleTypeRole="Shell" )],) |
---|
| 117 | |
---|
[369ac54] | 118 | #Get version |
---|
| 119 | import sasview |
---|
| 120 | VERSION = sasview.__version__ |
---|
| 121 | APPNAME = "SasView "+VERSION |
---|
| 122 | DMGNAME = "SasView-"+VERSION |
---|
| 123 | |
---|
[3a39c2e] | 124 | APP = ['sasview.py'] |
---|
| 125 | DATA_FILES += ['images','test','media'] |
---|
| 126 | |
---|
| 127 | EXCLUDES = ['PyQt4', 'sip', 'QtGui'] |
---|
| 128 | |
---|
| 129 | OPTIONS = {'argv_emulation': True, |
---|
| 130 | 'packages': ['lxml','numpy', 'scipy', 'pytz', 'encodings', |
---|
| 131 | 'encodings','matplotlib', 'periodictable', |
---|
| 132 | 'reportlab' |
---|
| 133 | ], |
---|
| 134 | 'iconfile': ICON, |
---|
| 135 | 'frameworks':[libxml_path], |
---|
| 136 | 'resources': RESOURCES_FILES, |
---|
| 137 | 'plist':plist, |
---|
| 138 | 'excludes' : EXCLUDES, |
---|
| 139 | } |
---|
| 140 | setup( |
---|
[369ac54] | 141 | name=APPNAME, |
---|
[3a39c2e] | 142 | app=APP, |
---|
| 143 | data_files=DATA_FILES, |
---|
| 144 | include_package_data= True, |
---|
| 145 | options={'py2app': OPTIONS}, |
---|
| 146 | setup_requires=['py2app'], |
---|
| 147 | ) |
---|
[369ac54] | 148 | |
---|
| 149 | #Build dmg |
---|
| 150 | DMG="dist/%s.dmg"%DMGNAME |
---|
| 151 | if os.path.exists(DMG): os.unlink(DMG) |
---|
[66b42f6] | 152 | os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME,APPNAME)) |
---|
[369ac54] | 153 | os.system('chmod a+r "%s"'%DMG) |
---|
| 154 | |
---|