source: sasview/installers/sasview_qt5.spec @ bb3b1c2

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since bb3b1c2 was bb3b1c2, checked in by Piotr Rozyczko <rozyczko@…>, 15 months ago

Fix for the qtconsole not working correctly

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