source: sasview/installers/sasview_qt5.spec @ a3221b6

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

Package SasView? with pyinstaller now. SASVIEW-906.
Minor issue with JupyterConsole? remaining.

  • Property mode set to 100644
File size: 5.4 KB
RevLine 
[a3221b6]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'))
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
74#import sas.sascalc.dataloader.readers
75#f = os.path.join(sas.sascalc.dataloader.readers.get_data_path(), 'defaults.json')
76#datas.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 'PyQt5',
114 'periodictable.core',
115 'sasmodels.core',
116 'pyopencl',
117 'tinycc',
118 'SocketServer',
119 'logging',
120 'logging.config',
121 'ipykernel', 'ipykernel.datapub',
122 'pygments', 'pygments.lexers','pygments.lexers.python',
123 'pygments.styles','pygments.styles.default',
124 'atexit', 'cython', 'sip', 'xhtml2pdf',
125 'zmq', 'zmq.utils', 'zmq.utils.strtypes',
126 'zmq.utils.jsonapi','zmq.utils.garbage',
127 'zmq.backend.cython','zmq.backend.cffi',
128 'site','lxml._elementpath','lxml.etree',
129]
130
131a = Analysis([SCRIPT_TO_SOURCE],
132             pathex=[WORK_DIR],
133             binaries=binaries,
134             datas=datas,
135             hiddenimports=hiddenimports,
136             hookspath=[],
137             runtime_hooks=[],
138             excludes=excludes,
139             win_no_prefer_redirects=False,
140             win_private_assemblies=False,
141             cipher=None)
142
143pyz = PYZ(a.pure, a.zipped_data,
144             cipher=None)
145
146exe = EXE(pyz,
147          a.scripts,
148          exclude_binaries=True,
149          name='sasview',
150          debug=False,
151          upx=UPX,
152          icon=os.path.join("../src/sas/sasview/images","ball.ico"),
153          version="version.txt",
154          console=False )
155
156# COLLECT creates a directory instead of a single file.
157coll = COLLECT(exe,
158               a.binaries,
159               a.zipfiles,
160               a.datas,
161               strip=False,
162               upx=UPX,
163               name='sasview')
164
165if platform.system() == 'Darwin':
166    app = BUNDLE(exe,
167        name='SasView.app',
168        icon='../src/sas/sasview/images/ball.ico',
169        bundle_identifier=None)
170
Note: See TracBrowser for help on using the repository browser.