source: sasview/installers/setup_mac.py @ 156203a

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 156203a was 156203a, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

default_categories.json was removed from installer

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