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

correct the location of logging.ini in setup_mac

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