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