source: sasview/installers/sasview.spec @ 156203a

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 156203a was 2f6d340, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

rename installers directory from sasview to installers

  • 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]
142
143a = Analysis([SCRIPT_TO_SOURCE],
144             pathex=[WORK_DIR],
145             binaries=binaries,
146             datas=datas,
147             hiddenimports=hiddenimports,
148             hookspath=[],
149             runtime_hooks=[],
150             excludes=excludes,
151             win_no_prefer_redirects=False,
152             win_private_assemblies=False,
153             cipher=None)
154
155pyz = PYZ(a.pure, a.zipped_data,
156             cipher=None)
157
158exe = EXE(pyz,
159          a.scripts,
160          exclude_binaries=True,
161          name='sasview',
162          debug=False,
163          upx=UPX,
164          icon=os.path.join("images","ball.ico"),
165          version="version.txt",
166          console=False )
167
168# COLLECT creates a directory instead of a single file.
169coll = COLLECT(exe,
170               a.binaries,
171               a.zipfiles,
172               a.datas,
173               strip=False,
174               upx=UPX,
175               name='sasview')
176
177if platform.system() == 'Darwin':
178    app = BUNDLE(exe,
179        name='SasView.app',
180        icon='images/ball.ico',
181        bundle_identifier=None)
182
Note: See TracBrowser for help on using the repository browser.