source: sasview/installers/setup_mac.py @ ed03b99

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalcmagnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since ed03b99 was ed03b99, checked in by Paul Kienzle <pkienzle@…>, 3 years ago

move logger config into root of sas so it is available immediately

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