source: sasview/sasview/setup_mac.py @ 11288e7c

Last change on this file since 11288e7c was 5a8cdbb, checked in by lewis, 7 years ago

Merge branch 'master' into ticket-876

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