forked from andrewkolb08/TOAK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
145 lines (117 loc) · 5.61 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from cx_Freeze import setup, Executable
import visvis as vv
import os, shutil, sys
import sys
backendAliases = {'qt4': 'pyqt4'}
def copyResources(destPath):
""" copyResources(destinationPath)
Copy the visvis resource dir to the specified folder
(The folder containing the frozen executable).
"""
# create folder (if required)
destPath = os.path.join(destPath, 'visvisResources')
if not os.path.isdir(destPath):
os.makedirs(destPath)
# copy files
path = vv.misc.getResourceDir()
for file in os.listdir(path):
if file.startswith('.') or file.startswith('_'):
continue
shutil.copy(os.path.join(path,file), os.path.join(destPath,file))
# copy FreeType library to resource dir
try:
ft_filename = 'freetype'
except Exception:
ft_filename = None
if ft_filename and not os.path.isfile(ft_filename):
# Try harder to get absolute path for the freetype lib
for dir in ['C:/Python27/Lib/site-packages/visvis/text', '/usr/local/lib/',
'/usr/lib/x86_64-linux-gnu/', '/usr/lib/i386-linux-gnu/']:
if os.path.isfile(dir+ft_filename):
ft_filename = dir+ft_filename
break
if ft_filename and os.path.isfile(ft_filename):
fname = os.path.split(ft_filename)[1]
shutil.copy(ft_filename, os.path.join(destPath,fname))
else:
print('Warning: could not copy freetype library.')
def getIncludes(backendName):
""" getIncludes(backendName)
Get a list of includes to extend the 'includes' list
with of py2exe or bbfreeze. The list contains:
* the module of the specified backend
* all the functionnames, which are dynamically loaded and therefore
not included by default.
* opengl stuff
"""
# init
includes = []
backendName = backendAliases.get(backendName, backendName)
# backend
backendModule = ('C:/Python27/Lib/site-packages/visvis/backends/backend_'+ backendName + '.py','backend_' +backendName+'.py')
includes.append(backendModule)
if backendName == 'pyqt4':
includes.extend([("C:/Python27/Lib/site-packages/PyQt4/sip","sip"),('C:/Python27/Lib/site-packages/PyQt4/sip/PyQt4/QtCore', "PyQt4.QtCore"), ("C:/Python27/Lib/site-packages/PyQt4/sip/PyQt4/QtGui","PyQt4.QtGui"), ("C:/Python27/Lib/site-packages/PyQt4/sip/PyQt4/QtOpenGL","PyQt4.QtOpenGL")])
elif backendName == 'pyside':
includes.extend(["PySide.QtCore", "PySide.QtGui", "PySide.QtOpenGL"])
# functions
for funcName in vv.functions._functionNames:
includes.append(('C:/Python27/Lib/site-packages/visvis/functions/'+funcName+'.py', funcName+'.py'))
# processing functions
for funcName in vv.processing._functionNames:
includes.append(('C:/Python27/Lib/site-packages/visvis/processing/'+funcName+'.py', funcName+'.py'))
# opengl stuff
arrayModules = [("C:/Python27/Lib/site-packages/OpenGL/arrays/nones.py",'nones.py'), ("C:/Python27/Lib/site-packages/OpenGL/arrays/strings.py",'strings.py'),("C:/Python27/Lib/site-packages/OpenGL/arrays/lists.py",'lists.py'),("C:/Python27/Lib/site-packages/OpenGL/arrays/numbers.py",'numbers.py'),("C:/Python27/Lib/site-packages/OpenGL/arrays/ctypesarrays.py",'cytypesarrays.py'),
("C:/Python27/Lib/site-packages/OpenGL/arrays/ctypesparameters.py",'ctypesparameters.py'), ("C:/Python27/Lib/site-packages/OpenGL/arrays/ctypespointers",'ctypespointers.py'), ("C:/Python27/Lib/site-packages/OpenGL/arrays/numpymodule.py",'numpymodule.py'),
("C:/Python27/Lib/site-packages/OpenGL/arrays/formathandler.py","formathandler.py")]
GLUModules = [("C:/Python27/Lib/site-packages/OpenGL/GLU/glustruct.py",'glustruct.py')]
for name in arrayModules:
if name in sys.modules:
includes.append(name)
for name in GLUModules:
if name in sys.modules:
includes.append(name)
if sys.platform.startswith('win'):
includes.append(("C:/Python27/Lib/site-packages/OpenGL/platform/win32.py",'win32.py'))
if sys.platform.startswith('linux'):
includes.append("OpenGL.platform.glx")
# done
return includes
def getExcludes(backendName):
""" getExcludes(backendName)
Get a list of excludes. If using the 'wx' backend, you don't
want all the qt4 libaries.
backendName is the name of the backend which you do want to use.
"""
# init
excludes = []
backendName = backendAliases.get(backendName, backendName)
# Neglect pyqt4
if 'pyqt4' != backendName:
excludes.extend(["sip", "PyQt4", "PyQt4.QtCore", "PyQt4.QtGui"])
# Neglect PySide
if 'pyside' != backendName:
excludes.extend(["PySide", "PySide.QtCore", "PySide.QtGui"])
# Neglect wx
if 'wx' != backendName:
excludes.extend(["wx"])
# done
return excludes
# Dependencies are automatically detected, but it might need
# fine tuning.
copyResources('VisTool')
buildOptions = dict(packages = ["os"], include_files = getIncludes('pyqt4'), excludes = [])
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('visualizationTool.py', base=base, targetName = 'VisTool')
]
options = {
'build_exe': {
'includes': 'atexit'
}
}
setup(name='VisTool',
version = '1.0',
description = 'Tool for visualization of EMA sensor data in real-time',
options = dict(build_exe = buildOptions),
executables = executables)