source: sasview/installers/setup_mac.py @ b708b2a

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

correct the location of logging.ini in setup_mac

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