source: sasview/installers/sasview_qt5_osx.spec @ eb0d26c

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 eb0d26c was eb0d26c, checked in by wojciech, 2 years ago

App name changed to more descriptive

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