source: sasview/installers/sasview.spec @ b5cc06e

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since b5cc06e was f4a1433, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Merge branch 'master' into ESS_GUI

  • Property mode set to 100644
File size: 4.8 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# pyinstaller gets mightily confused by upper/lower case,
54# so some modules need to be copied explicitly to avoid
55# messages like
56# WARNING: Attempted to add Python module twice with different upper/lowercases
57datas.append((os.path.join(PYTHON_LOC,'Lib','SocketServer.py'),'.'))
58datas.append((os.path.join(PYTHON_LOC,'Lib','Queue.py'),'.'))
59
60# TODO
61# NEED BETTER WAY TO DEAL WITH THESE RELATIVE PATHS
62datas.append((os.path.join('..','..','sasmodels','sasmodels'),'sasmodels'))
63datas.append((os.path.join('..','src','sas','sasgui','perspectives','fitting','plugin_models'),'plugin_models'))
64
65# These depend on whether we have MKL or Atlas numpy
66if os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'mkl_core.' + LIBSUFFIX)):
67    datas.append(add_binary(LIBPREFIX + 'mkl_avx2.' + LIBSUFFIX))
68    datas.append(add_binary(LIBPREFIX + 'mkl_def.' + LIBSUFFIX))
69elif os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX)):
70    datas.append(add_binary(LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX))
71else:
72    raise Exception("No numerical library for numpy found.")
73
74import sas.sascalc.dataloader.readers
75f = os.path.join(sas.sascalc.dataloader.readers.get_data_path(), 'defaults.json')
76datas.append((f, '.'))
77
78# Add a custom pyopencl hook, as described in
79# https://github.com/pyinstaller/pyinstaller/issues/2130
80from PyInstaller.utils.hooks import copy_metadata
81datas.append(copy_metadata('pyopencl')[0])
82
83import sasmodels
84add_data(sasmodels.data_files())
85
86try:
87    import tinycc
88    add_data(tinycc.data_files())
89except ImportError:
90    warnings.warn("TinyCC package is not available and will not be included")
91
92import periodictable
93add_data(periodictable.data_files())
94
95import matplotlib
96matplotlibdatadir = matplotlib.get_data_path()
97matplotlibdata = findall(matplotlibdatadir)
98for f in matplotlibdata:
99    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
100    datas.append((f, os.path.split(dirname)[0]))
101
102binaries = []
103
104# EXCLUDED FILES ############################################################
105# Spelled out to enable easier editing
106excludes = []
107
108# Need to explicitly exclude sasmodels here!!
109excludes.append('sasmodels')
110
111# HIDDEN MODULES ############################################################
112hiddenimports = [
113 'periodictable.core',
114 'sasmodels.core',
115 'pyopencl',
116 'tinycc',
117 'SocketServer'
118]
119
120a = Analysis([SCRIPT_TO_SOURCE],
121             pathex=[WORK_DIR],
122             binaries=binaries,
123             datas=datas,
124             hiddenimports=hiddenimports,
125             hookspath=[],
126             runtime_hooks=[],
127             excludes=excludes,
128             win_no_prefer_redirects=False,
129             win_private_assemblies=False,
130             cipher=None)
131
132pyz = PYZ(a.pure, a.zipped_data,
133             cipher=None)
134
135exe = EXE(pyz,
136          a.scripts,
137          exclude_binaries=True,
138          name='sasview',
139          debug=False,
140          upx=UPX,
141          icon=os.path.join("images","ball.ico"),
142          version="version.txt",
143          console=False )
144
145# COLLECT creates a directory instead of a single file.
146coll = COLLECT(exe,
147               a.binaries,
148               a.zipfiles,
149               a.datas,
150               strip=False,
151               upx=UPX,
152               name='sasview')
153
154if platform.system() == 'Darwin':
155    app = BUNDLE(exe,
156        name='SasView.app',
157        icon='images/ball.ico',
158        bundle_identifier=None)
159
Note: See TracBrowser for help on using the repository browser.