source: sasview/installers/sasview_qt5_osx.spec @ d8f4d9b

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 d8f4d9b was 44753d6, checked in by wojciech, 6 years ago

Fixing osx spec file

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