source: sasview/installers/sasview.spec @ 724af06

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

Merge branch 'master' into ticket-887-reorg

  • Property mode set to 100755
File size: 5.5 KB
Line 
1# -*- mode: python -*-
2# Modifiable location
3import sys
4import os
5import platform
6
7import warnings
8from distutils.filelist import findall
9
10PYTHON_LOC = sys.exec_prefix
11# Portability settings
12if os.name == 'posix':
13    LIBPREFIX='lib'
14    LIBSUFFIX='so'
15    LIBLOC = os.path.join(PYTHON_LOC,'lib')
16    # Darwin needs UPX=False, Linux actually builds with both...
17    if platform.system() == 'Darwin':
18        UPX=False
19    else:
20        UPX=True
21else:
22    LIBPREFIX=''
23    LIBSUFFIX='dll'
24    LIBLOC = os.path.join(PYTHON_LOC,'Library','bin')
25    UPX=True
26
27SCRIPT_TO_SOURCE = 'sasview.py'
28
29# Warning! pyinstaller/py2exe etc. don't have the __file__ attribute
30# WORK_DIR = os.path.dirname(os.path.realpath(__file__))
31WORK_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
32
33#### LOCAL METHODS
34def add_data(data):
35    for component in data:
36        target = component[0]
37        for filename in component[1]:
38           datas.append((filename, target))
39
40def add_binary(binary):
41    return (os.path.join(LIBLOC,binary),'.')
42
43# ADDITIONAL DATA ############################################################
44datas = [('images', 'images')]
45
46datas.append(('media','media'))
47datas.append(('test','test'))
48datas.append(('custom_config.py','.'))
49datas.append(('local_config.py','.'))
50datas.append(('wxcruft.py','.'))
51datas.append(('welcome_panel.py','.'))
52
53# TODO
54# NEED BETTER WAY TO DEAL WITH THESE RELATIVE PATHS
55datas.append((os.path.join('..','..','sasmodels','sasmodels'),'sasmodels'))
56datas.append((os.path.join('..','src','sas','sasgui','perspectives','fitting','plugin_models'),'plugin_models'))
57
58# precompile sas models into the sasview build path; doesn't matter too much
59# where it is so long as it is a place that will get cleaned up afterwards.
60import sasmodels.core
61dll_path = 'compiled_models'
62if not (os.path.exists(dll_path)):
63    os.mkdir(dll_path)
64dll_path2 = os.path.join(dll_path, dll_path)
65if not (os.path.exists(dll_path2)):
66    os.mkdir(dll_path2)
67
68compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')
69
70# include the compiled models as data; coordinate the target path for the
71# data with installer_generator.py
72datas.append((os.path.join('compiled_models','compiled_models'),'compiled_models'))
73
74# These depend on whether we have MKL or Atlas numpy
75if os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'mkl_core.' + LIBSUFFIX)):
76    datas.append(add_binary(LIBPREFIX + 'mkl_avx2.' + LIBSUFFIX))
77    datas.append(add_binary(LIBPREFIX + 'mkl_def.' + LIBSUFFIX))
78elif os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX)):
79    datas.append(add_binary(LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX))
80else:
81    raise Exception("No numerical library for numpy found.")
82
83import sas.sascalc.dataloader.readers
84f = os.path.join(sas.sascalc.dataloader.readers.get_data_path(), 'defaults.json')
85datas.append((f, '.'))
86
87# Add a custom pyopencl hook, as described in
88# https://github.com/pyinstaller/pyinstaller/issues/2130
89from PyInstaller.utils.hooks import copy_metadata
90datas.append(copy_metadata('pyopencl')[0])
91
92import sasmodels
93add_data(sasmodels.data_files())
94
95try:
96    import tinycc
97    add_data(tinycc.data_files())
98except ImportError:
99    warnings.warn("TinyCC package is not available and will not be included")
100
101import periodictable
102add_data(periodictable.data_files())
103
104import matplotlib
105matplotlibdatadir = matplotlib.get_data_path()
106matplotlibdata = findall(matplotlibdatadir)
107for f in matplotlibdata:
108    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
109    datas.append((f, os.path.split(dirname)[0]))
110
111binaries = []
112
113# EXCLUDED FILES ############################################################
114# Spelled out to enable easier editing
115excludes = []
116excludes.append('libzmq')
117excludes.append('IPython')
118excludes.append('PyQt4')
119excludes.append('PySide')
120excludes.append('Qt4')
121excludes.append('Tkinter')
122excludes.append('tk')
123excludes.append('tcl')
124# Seems we cannot build on Linux without bundling sip
125if not platform.system() == 'Linux':
126    excludes.append('sip')
127excludes.append('sympy')
128excludes.append('pytz')
129excludes.append('sklearn')
130excludes.append('zmq')
131
132# Need to explicitly exclude sasmodels here!!
133excludes.append('sasmodels')
134
135# HIDDEN MODULES ############################################################
136hiddenimports = [
137 'periodictable.core',
138 'sasmodels.core',
139 'pyopencl',
140 'tinycc',
141 'xhtml2pdf'
142]
143
144a = Analysis([SCRIPT_TO_SOURCE],
145             pathex=[WORK_DIR],
146             binaries=binaries,
147             datas=datas,
148             hiddenimports=hiddenimports,
149             hookspath=[],
150             runtime_hooks=[],
151             excludes=excludes,
152             win_no_prefer_redirects=False,
153             win_private_assemblies=False,
154             cipher=None)
155
156pyz = PYZ(a.pure, a.zipped_data,
157             cipher=None)
158
159exe = EXE(pyz,
160          a.scripts,
161          exclude_binaries=True,
162          name='sasview',
163          debug=False,
164          upx=UPX,
165          icon=os.path.join("images","ball.ico"),
166          version="version.txt",
167          console=False )
168
169# COLLECT creates a directory instead of a single file.
170coll = COLLECT(exe,
171               a.binaries,
172               a.zipfiles,
173               a.datas,
174               strip=False,
175               upx=UPX,
176               name='sasview')
177
178if platform.system() == 'Darwin':
179    app = BUNDLE(exe,
180        name='SasView.app',
181        icon='images/ball.ico',
182        bundle_identifier=None)
183
Note: See TracBrowser for help on using the repository browser.