source: sasview/sasview/cx_setup.py @ 9909967

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

SASVIEW-629: script for building SasviewQt? executable

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[9909967]1import os
2import sys
3import scipy
4import matplotlib
5import cython
6
7import zmq.libzmq
8import periodictable
9import sasmodels
10import sasmodels.core
11
12from cx_Freeze import setup
13from cx_Freeze import Executable
14from distutils.filelist import findall
15from distutils.sysconfig import get_python_lib
16from distutils.filelist import findall
17from distutils.util import get_platform
18
19try:
20    import tinycc
21except ImportError:
22    warnings.warn("TinyCC package is not available and will not be included")
23    tinycc = None
24
25# Full path to sasview/build/lib.<platform>-2.7
26root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
27platform = '%s-%s'%(get_platform(), sys.version[:3])
28build_path = os.path.join(root, 'build', 'lib.'+platform)
29sys.path.insert(0, build_path)
30python_root = os.path.dirname(os.path.abspath(sys.executable))
31
32
33# Excluded packages
34excl = ['collections.sys', 'collections._weakref', 'Tkinter']
35
36# Explicityl included modules
37incl = [
38'pygments', 'pygments.lexers','pygments.lexers.python',
39'pygments.styles','pygments.styles.default',
40'ipykernel', 'ipykernel.datapub',
41'atexit', 'cython', 'sip', 'xhtml2pdf',
42'zmq', 'zmq.utils', 'zmq.utils.strtypes',
43'zmq.utils.jsonapi','zmq.utils.garbage',
44'zmq.backend.cython','zmq.backend.cffi',
45'site','lxml._elementpath','lxml.etree',
46]
47
48# Extra packages
49packs = [
50'periodictable.core',
51'matplotlib',
52'encodings',
53'comtypes',
54'bumps',
55'sasmodels',
56'win32com',
57]
58
59if tinycc:
60    packs.append('tinycc')
61
62
63# Holder for extra files
64data_files = []
65
66data_files.append(zmq.libzmq.__file__)
67data_files.append("local_config.py")
68data_files.append("custom_config.py")
69data_files.append("logging.ini")
70data_files.append("media/")
71data_files.append("images/")
72data_files.append("test/")
73data_files.append("plugin_models/")
74
75def append_data(tups):
76    # Convert py2exe tuple into cx_freeze tuple
77    for tup in tups:
78      target = tup[0]
79      files = tup[1]
80      for file in files:
81         basename = os.path.basename(file)
82         t = os.path.join(target, basename)
83         data_files.append((file, t))
84
85# Documents
86doc_source = os.path.join(build_path, 'doc/')
87data_files.append((doc_source, 'doc/'))
88
89# OPENCL
90site_loc = get_python_lib()
91opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")
92for f in findall(opencl_include_dir):
93    target = os.path.join("includes", "pyopencl", os.path.basename(f))
94    data_files.append((f, target))
95
96
97append_data(periodictable.data_files())
98append_data(sasmodels.data_files())
99if tinycc:
100    append_data(tinycc.data_files())
101
102# 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    target = os.path.join(dirname, os.path.basename(f))
108    data_files.append((f, dirname))
109
110# Numerical libraries
111def dll_check(dll_path, dlls):
112    dll_includes = [os.path.join(dll_path, dll+'.dll') for dll in dlls]
113    return [dll for dll in dll_includes if os.path.exists(dll)]
114
115# Check for ATLAS
116dll_path = os.path.join(python_root, 'lib', 'site-packages', 'numpy', 'core')
117dlls = ['numpy-atlas']
118atlas_dlls = dll_check(dll_path, dlls)
119
120# Check for MKL
121dll_path = os.path.join(python_root, 'Library', 'bin')
122dlls = ['mkl_core', 'mkl_def', 'libiomp5md', 'libmmd',
123        'libmmdd', 'libiomp5md', 'libifcoremd', 'libifcoremdd']
124mkl_dlls = dll_check(dll_path, dlls)
125
126to_include = mkl_dlls
127if atlas_dlls:
128    to_include = atlas_dlls
129
130for library in to_include:
131    target = os.path.basename(library)
132    data_files.append((library, target))
133
134
135# Precompile models and add them
136dll_path = os.path.join(build_path, 'compiled_models')
137#compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')
138#for library in compiled_dlls:
139#    target = os.path.join('compiled_models', os.path.basename(library))
140#    data_files.append((library, target))
141
142# Extra logic for scipy
143scipy_path = os.path.dirname(scipy.__file__)
144data_files.append(scipy_path)
145
146
147buildOptions = dict(packages = packs, excludes = excl, includes = incl,
148                    include_files = data_files)
149
150
151base = 'Win32GUI' if sys.platform=='win32' else None
152
153icon = os.path.join('images','ball.ico')
154
155executables = [
156    Executable('sasview.py', 
157               icon=icon,
158               base=base)
159]
160
161setup(
162    name='sasview',
163    version = '5.0',
164    description = 'SasviewQt Program',
165    options = dict(build_exe = buildOptions),
166    executables = executables
167)
168
169
Note: See TracBrowser for help on using the repository browser.