source: sasview/sasview/setup_mac.py @ 899e084

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

build console app as well as gui

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