source: sasview/installers/sasview_qt5.spec @ c889a3e

ESS_GUIESS_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 c889a3e was aefde77, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Minor modifications to allow jupyter console to be bundled

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[aefde77]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
30WORK_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
31
32#### LOCAL METHODS
33def add_data(data):
34    for component in data:
35        target = component[0]
36        for filename in component[1]:
37           datas.append((filename, target))
38
39def add_binary(binary):
40    return (os.path.join(LIBLOC,binary),'.')
41
42# ADDITIONAL DATA ############################################################
43datas = [('../src/sas/sasview/images', 'images')]
44
45datas.append(('../src/sas/sasview/media','media'))
46datas.append(('../src/sas/sasview/test','test'))
47datas.append(('../src/sas/sasview/custom_config.py','.'))
48datas.append(('../src/sas/sasview/local_config.py','.'))
49datas.append(('../src/sas/sasview/wxcruft.py','.'))
50datas.append(('../src/sas/logger_config.py','.'))
51
52# pyinstaller gets mightily confused by upper/lower case,
53# so some modules need to be copied explicitly to avoid
54# messages like
55# WARNING: Attempted to add Python module twice with different upper/lowercases
56datas.append((os.path.join(PYTHON_LOC,'Lib','SocketServer.py'),'.'))
57datas.append((os.path.join(PYTHON_LOC,'Lib','Queue.py'),'.'))
58
59# TODO
60# NEED BETTER WAY TO DEAL WITH THESE RELATIVE PATHS
61datas.append((os.path.join('..', '..','sasmodels','sasmodels'),'sasmodels'))
62datas.append((os.path.join('..', 'src','sas','sasgui','perspectives','fitting','plugin_models'),'plugin_models'))
63datas.append((os.path.join(PYTHON_LOC,'Library','plugins','platforms'),'platforms'))
64datas.append((os.path.join(PYTHON_LOC,'Lib','site-packages','zmq','libzmq.cp36-win_amd64.pyd'),'.'))
65
66# These depend on whether we have MKL or Atlas numpy
67if os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'mkl_core.' + LIBSUFFIX)):
68    datas.append(add_binary(LIBPREFIX + 'mkl_avx2.' + LIBSUFFIX))
69    datas.append(add_binary(LIBPREFIX + 'mkl_def.' + LIBSUFFIX))
70elif os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX)):
71    datas.append(add_binary(LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX))
72else:
73    raise Exception("No numerical library for numpy found.")
74
75#import sas.sascalc.dataloader.readers
76#f = os.path.join(sas.sascalc.dataloader.readers.get_data_path(), 'defaults.json')
77#datas.append((f, '.'))
78
79# Add a custom pyopencl hook, as described in
80# https://github.com/pyinstaller/pyinstaller/issues/2130
81from PyInstaller.utils.hooks import copy_metadata
82datas.append(copy_metadata('pyopencl')[0])
83
84import sasmodels
85add_data(sasmodels.data_files())
86
87try:
88    import tinycc
89    add_data(tinycc.data_files())
90except ImportError:
91    warnings.warn("TinyCC package is not available and will not be included")
92
93import periodictable
94add_data(periodictable.data_files())
95
96import matplotlib
97matplotlibdatadir = matplotlib.get_data_path()
98matplotlibdata = findall(matplotlibdatadir)
99for f in matplotlibdata:
100    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
101    datas.append((f, os.path.split(dirname)[0]))
102
103binaries = []
104
105# EXCLUDED FILES ############################################################
106# Spelled out to enable easier editing
107excludes = []
108
109# Need to explicitly exclude sasmodels here!!
110excludes.append('sasmodels')
111
112# HIDDEN MODULES ############################################################
113hiddenimports = [
114 'PyQt5',
115 'periodictable.core',
116 'sasmodels.core',
117 'pyopencl',
118 'tinycc',
119 'SocketServer',
120 'logging',
121 'logging.config',
122 'ipykernel', 'ipykernel.datapub',
[a3221b6]123 'pygments', 'pygments.lexers','pygments.lexers.python',
124 'pygments.styles','pygments.styles.default',
[aefde77]125 'atexit', 'cython', 'sip', 'xhtml2pdf',
[a3221b6]126 'zmq', 'zmq.utils', 'zmq.utils.strtypes',
127 'zmq.utils.jsonapi','zmq.utils.garbage',
[aefde77]128 'zmq.backend.cython','zmq.backend.cffi',
129 'site','lxml._elementpath','lxml.etree',
130 'scipy._lib.messagestream',
131]
132
133a = Analysis([SCRIPT_TO_SOURCE],
134             pathex=[WORK_DIR],
135             binaries=binaries,
136             datas=datas,
137             hiddenimports=hiddenimports,
138             hookspath=[],
139             runtime_hooks=[],
140             excludes=excludes,
141             win_no_prefer_redirects=False,
142             win_private_assemblies=False,
143             cipher=None)
144
145pyz = PYZ(a.pure, a.zipped_data,
146             cipher=None)
147
148exe = EXE(pyz,
149          a.scripts,
150          exclude_binaries=True,
151          name='sasview',
152          debug=False,
153          upx=UPX,
154          icon=os.path.join("../src/sas/sasview/images","ball.ico"),
155          version="version.txt",
156          console=False )
157
158# COLLECT creates a directory instead of a single file.
159coll = COLLECT(exe,
160               a.binaries,
161               a.zipfiles,
162               a.datas,
163               strip=False,
164               upx=UPX,
165               name='sasview')
166
167if platform.system() == 'Darwin':
168    app = BUNDLE(exe,
169        name='SasView.app',
170        icon='../src/sas/sasview/images/ball.ico',
171        bundle_identifier=None)
172
Note: See TracBrowser for help on using the repository browser.