source: sasview/installers/sasview_qt5_osx.spec @ 473a85a

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_sync_sascalc
Last change on this file since 473a85a was 38f4bc6, checked in by wojciech, 6 years ago

Adding support for retina screen on OSX

  • Property mode set to 100644
File size: 6.4 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'))
67datas.append((os.path.join(PYTHON_LOC,'lib','python3.6', 'site-packages','jedi'),'jedi'))
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'),'.'))
73# These depend on whether we have MKL or Atlas numpy
74#if 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))
77#elif os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX)):
78#    datas.append(add_binary(LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX))
79#else:
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.icns"),
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':
187    app = BUNDLE(coll,
188        name='SasView5.0.app',
189        icon='../src/sas/sasview/images/ball.icns',
190        bundle_identifier=None,
191        info_plist={'NSHighResolutionCapable': 'True'})
192
Note: See TracBrowser for help on using the repository browser.