source: sasview/build_tools/cx_setup.py @ 0101c9f

Last change on this file since 0101c9f was d6b234b, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Cleanup after merge (removed sasview/sasview)

  • Property mode set to 100644
File size: 4.4 KB
Line 
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/")
74data_files.append("compiled_models/")
75
76def append_data(tups):
77    # Convert py2exe tuple into cx_freeze tuple
78    for tup in tups:
79      target = tup[0]
80      files = tup[1]
81      for file in files:
82         basename = os.path.basename(file)
83         t = os.path.join(target, basename)
84         data_files.append((file, t))
85
86# Documents
87doc_source = os.path.join(build_path, 'doc/')
88data_files.append((doc_source, 'doc/'))
89
90# OPENCL
91site_loc = get_python_lib()
92opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")
93for f in findall(opencl_include_dir):
94    target = os.path.join("includes", "pyopencl", os.path.basename(f))
95    data_files.append((f, target))
96
97
98append_data(periodictable.data_files())
99append_data(sasmodels.data_files())
100if tinycc:
101    append_data(tinycc.data_files())
102
103# 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    target = os.path.join(dirname, os.path.basename(f))
109    data_files.append((f, dirname))
110
111# Numerical libraries
112def dll_check(dll_path, dlls):
113    dll_includes = [os.path.join(dll_path, dll+'.dll') for dll in dlls]
114    return [dll for dll in dll_includes if os.path.exists(dll)]
115
116# Check for ATLAS
117dll_path = os.path.join(python_root, 'lib', 'site-packages', 'numpy', 'core')
118dlls = ['numpy-atlas']
119atlas_dlls = dll_check(dll_path, dlls)
120
121# Check for MKL
122dll_path = os.path.join(python_root, 'Library', 'bin')
123dlls = ['mkl_core', 'mkl_def', 'libiomp5md', 'libmmd',
124        'libmmdd', 'libiomp5md', 'libifcoremd', 'libifcoremdd']
125mkl_dlls = dll_check(dll_path, dlls)
126
127to_include = mkl_dlls
128if atlas_dlls:
129    to_include = atlas_dlls
130
131for library in to_include:
132    target = os.path.basename(library)
133    data_files.append((library, target))
134
135
136# Precompile models and add them
137dll_path = os.path.join(build_path, 'compiled_models')
138#compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')
139#for library in compiled_dlls:
140#    target = os.path.join('compiled_models', os.path.basename(library))
141#    data_files.append((library, target))
142
143# Extra logic for scipy
144scipy_path = os.path.dirname(scipy.__file__)
145data_files.append(scipy_path)
146
147
148buildOptions = dict(packages = packs, excludes = excl, includes = incl,
149                    include_files = data_files)
150
151
152base = 'Win32GUI' if sys.platform=='win32' else None
153
154icon = os.path.join('images','ball.ico')
155
156executables = [
157    Executable('sasview.py', 
158               icon=icon,
159               base=base)
160]
161
162setup(
163    name='sasview',
164    version = '5.0',
165    description = 'SasviewQt Program',
166    options = dict(build_exe = buildOptions),
167    executables = executables
168)
169
170
Note: See TracBrowser for help on using the repository browser.