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@…>, 3 years ago

default_categories.json was removed from installer

  • Property mode set to 100644
File size: 7.0 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,
10               change the following line in py2app/recipes/matplotlib.py
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"""
14from __future__ import print_function
15
16import os
17import string
18import sys
19
20from distutils.util import get_platform
21from distutils.filelist import findall
22from distutils.sysconfig import get_python_lib
23
24from setuptools import setup
25
26import macholib_patch
27
28root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
29platform = '%s-%s'%(get_platform(), sys.version[:3])
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
34#Extending recursion limit
35sys.setrecursionlimit(10000)
36
37print("BUILDING PATH INSIDE", env)
38
39from sas.sasview import local_config
40
41ICON = local_config.SetupIconFile_mac
42RESOURCES_FILES = []
43DATA_FILES = []
44
45#Periodictable data file
46import periodictable
47DATA_FILES += periodictable.data_files()
48#invariant and calculator help doc
49from sas.sasgui.perspectives import fitting
50DATA_FILES += fitting.data_files()
51from sas.sasgui.perspectives import calculator
52DATA_FILES += calculator.data_files()
53from sas.sasgui.perspectives import invariant
54DATA_FILES += invariant.data_files()
55import sasmodels
56DATA_FILES += sasmodels.data_files()
57from sas.sasgui import guiframe
58DATA_FILES += guiframe.data_files()
59
60#CANSAxml reader data files
61from sas.sascalc.dataloader import readers
62RESOURCES_FILES.append(os.path.join(readers.get_data_path(), 'defaults.json'))
63
64# Copy the config files
65sas_path = os.path.join('..', 'src', 'sas')
66DATA_FILES.append(('.', [os.path.join(sas_path, 'logging.ini')]))
67sasview_path = os.path.join(sas_path, 'sasview')
68custom_config_file = os.path.join(sasview_path, 'custom_config.py')
69local_config_file = os.path.join(sasview_path, 'local_config.py')
70logging_ini = os.path.join(sas_path, 'logging.ini')
71DATA_FILES.append(('.', [custom_config_file]))
72DATA_FILES.append(('config', [custom_config_file]))
73DATA_FILES.append(('.', [local_config_file]))
74DATA_FILES.append(('.', [logging_ini]))
75
76if os.path.isfile("BUILD_NUMBER"):
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):
97    DATA_FILES.append((os.path.join("test", "1d_data"), [f]))
98
99# Copying the sample data user data
100for f in findall(test_2d_dir):
101    DATA_FILES.append((os.path.join("test", "2d_data"), [f]))
102
103# Copying the sample data user data
104for f in findall(test_save_dir):
105    DATA_FILES.append((os.path.join("test", "save_states"), [f]))
106
107# Copying the sample data user data
108for f in findall(test_upcoming_dir):
109    DATA_FILES.append((os.path.join("test", "upcoming_formats"), [f]))
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):
115    DATA_FILES.append((os.path.join("includes", "pyopencl"), [f]))
116
117# See if the documentation has been built, and if so include it.
118print(doc_path)
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:
133        extensions = []
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)
140            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
141                extensions.append(ext)
142    except Exception:
143        pass
144    try:
145        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1)
146        if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
147            extensions.append(ext)
148    except Exception:
149        pass
150    try:
151        for item in local_config.PLUGINS_WLIST:
152            file_type, ext = string.split(item, "|*.", 1)
153            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in extensions:
154                extensions.append(ext)
155    except Exception:
156        pass
157
158    return extensions
159
160EXTENSIONS_LIST = find_extension()
161
162
163plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST,
164                                         CFBundleTypeIconFile=ICON,
165                                         CFBundleTypeName="sasview file",
166                                         CFBundleTypeRole="Shell")],)
167
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
175if libxml_path is None:
176    raise RuntimeError, "Could not find libxml2 on the system"
177
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
182from sas.sasview import __version__ as VERSION
183APPNAME = "SasView "+VERSION
184DMGNAME = "SasView-"+VERSION+"-MacOSX"
185APP = ['sasview_gui.py']
186
187EXCLUDES = ['PyQt4', 'sip', 'QtGui']
188
189OPTIONS = {'argv_emulation': True,
190           'packages': ['lxml', 'numpy', 'scipy', 'pytz', 'encodings',
191                        'encodings', 'matplotlib', 'periodictable',
192                        'reportlab', 'sasmodels', 'pyopencl', 'h5py',
193                       ],
194           'iconfile': ICON,
195           'frameworks': [libxml_path],
196           'resources': RESOURCES_FILES,
197           'plist': plist,
198           'excludes' : EXCLUDES,
199          }
200setup(
201    name=APPNAME,
202    app=APP,
203    data_files=DATA_FILES,
204    include_package_data=True,
205    options={'py2app': OPTIONS},
206    setup_requires=['py2app'],
207)
208
209#Build dmg
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))
214os.system('chmod a+r "%s"'%DMG)
Note: See TracBrowser for help on using the repository browser.