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