source: sasview/sasview/setup_mac.py @ d66dbcc

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

complete the merge

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