source: sasview/sasview/setup_mac.py @ 3aa2f3c

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

working mac build with revised tree

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