source: sasview/installers/setup_mac.py @ 92df9cbd

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

bundler resources by directory

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