source: sasview/installers/sasview_qt5_commercial.spec @ 17f7df4

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_sync_sascalc
Last change on this file since 17f7df4 was 17f7df4, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 5 years ago

Added yml and spec files for commercial PyQt? package. SASVIEW-961

  • Property mode set to 100644
File size: 6.0 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'))
66#datas.append((os.path.join(PYTHON_LOC,'Library','plugins','platforms'),'platforms'))
67datas.append((os.path.join(PYTHON_LOC,'Lib','site-packages','PyQt5','Qt','plugins','platforms'),'platforms'))
68datas.append((os.path.join(PYTHON_LOC,'Lib','site-packages','jedi'),'jedi'))
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 'PyQt5.sip',
120 'periodictable.core',
121 'sasmodels.core',
122 'pyopencl',
123 'tinycc',
124 'SocketServer',
125 'logging',
126 'logging.config',
127 'reportlab', 'reportlab.graphics',
128 'reportlab.graphics.barcode.common',
129 'reportlab.graphics.barcode.code128',
130 'reportlab.graphics.barcode.code93',
131 'reportlab.graphics.barcode.code39',
132 'reportlab.graphics.barcode.lto',
133 'reportlab.graphics.barcode.qr',
134 'reportlab.graphics.barcode.usps',
135 'reportlab.graphics.barcode.usps4s',
136 'reportlab.graphics.barcode.eanbc',
137 'reportlab.graphics.barcode.ecc200datamatrix',
138 'reportlab.graphics.barcode.fourstate',
139 'ipykernel', 'ipykernel.datapub',
140 'pygments', 'pygments.lexers','pygments.lexers.python',
141 'pygments.styles','pygments.styles.default',
142 'atexit', 'cython', 'sip', 'xhtml2pdf',
143 'zmq', 'zmq.utils', 'zmq.utils.strtypes',
144 'zmq.utils.jsonapi','zmq.utils.garbage',
145 'zmq.backend.cython','zmq.backend.cffi',
146 'site','lxml._elementpath','lxml.etree',
147 'scipy._lib.messagestream',
148]
149
150a = Analysis([SCRIPT_TO_SOURCE],
151             pathex=[WORK_DIR],
152             binaries=binaries,
153             datas=datas,
154             hiddenimports=hiddenimports,
155             hookspath=[],
156             runtime_hooks=[],
157             excludes=excludes,
158             win_no_prefer_redirects=False,
159             win_private_assemblies=False,
160             cipher=None)
161
162pyz = PYZ(a.pure, a.zipped_data,
163             cipher=None)
164
165exe = EXE(pyz,
166          a.scripts,
167          exclude_binaries=True,
168          name='sasview',
169          debug=False,
170          upx=UPX,
171          icon=os.path.join("../src/sas/sasview/images","ball.ico"),
172          version="version.txt",
173          console=False )
174
175# COLLECT creates a directory instead of a single file.
176coll = COLLECT(exe,
177               a.binaries,
178               a.zipfiles,
179               a.datas,
180               strip=False,
181               upx=UPX,
182               name='sasview')
183
184if platform.system() == 'Darwin':
185    app = BUNDLE(exe,
186        name='SasView.app',
187        icon='../src/sas/sasview/images/ball.ico',
188        bundle_identifier=None)
189
Note: See TracBrowser for help on using the repository browser.