forked from open-cogsci/OpenSesame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-mac.py
129 lines (110 loc) · 3.92 KB
/
setup-mac.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
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
This file is part of OpenSesame.
OpenSesame is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSesame is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenSesame. If not, see <http://www.gnu.org/licenses/>.
This scripts builds OpenSesame as a standalone application for Mac OS.
Usage:
python setup-mac.py py2app
"""
from setuptools import setup
import os
import shutil
from setup_shared import included_plugins, included_extensions
from libopensesame.metadata import __version__ as version, codename
# Clean up previous builds
try:
shutil.rmtree("dist")
except:
pass
try:
shutil.rmtree("build")
except:
pass
# Copy qt_menu.nib folder
try:
shutil.rmtree("qt_menu.nib")
except:
pass
shutil.copytree("/Users/daniel/anaconda/python.app/Contents/Resources/qt_menu.nib", "qt_menu.nib")
# Py2app doesn't like extensionless Python scripts
try:
os.remove("opensesame.py")
os.remove("opensesamerun.py")
except:
pass
shutil.copyfile("opensesame", "opensesame.py")
shutil.copyfile("opensesamerun", "opensesamerun.py")
# Build!
setup(
app = ['opensesame.py'],
data_files = ['opensesame.py'],
options = {'py2app' :
{
'argv_emulation': True,
'includes' : [
'PyQt4.QtNetwork', 'serial', 'opensesamerun', 'skimage', 'sip', \
'billiard',
],
'excludes': [
'Finder','idlelib', 'gtk', 'matplotlib', 'pandas', 'PyQt4.QtDesigner',\
'PyQt4.QtOpenGL', 'PyQt4.QtScript', 'PyQt4.QtSql', 'PyQt4.QtTest', \
'PyQt4.QtXml', 'PyQt4.phonon', 'rpy2', 'wx', 'pycurl','mkl','dynd','bokeh',
],
'resources' : ['qt_menu.nib', 'resources', 'sounds', 'help', 'data'],
'packages' : [
'openexp','expyriment','psychopy','QProgEdit','libqtopensesame','libopensesame',\
'IPython','ipykernel','jupyter_client','qtconsole','pygments','OpenGL_accelerate',
],
'iconfile' : 'resources/opensesame.icns',
'plist': {
'CFBundleName': 'OpenSesame',
'CFBundleShortVersionString': version,
'CFBundleVersion': ' '.join([version, codename]),
'CFBundleIdentifier':'nl.cogsci.osdoc',
'NSHumanReadableCopyright': 'Sebastiaan Mathot (2010-2016)',
'CFBundleDevelopmentRegion': 'English',
'CFBundleDocumentTypes': [
{
'CFBundleTypeExtensions' : ['osexp'],
'CFBundleTypeIconFile' : 'resources/opensesame.icns',
'CFBundleTypeRole' : 'Editor',
'CFBundleTypeName' : 'OpenSesame File',
},
]
}
}
},
setup_requires=['py2app'],
)
# Clean up qt_menu.nib
shutil.rmtree("qt_menu.nib")
# Psychopy monitor center does not play nicely together with the OpenSesame GUI
if 'psychopy_monitor_center' in included_extensions:
del included_extensions[included_extensions.index('psychopy_monitor_center')]
# Copy extensions into app
for extension in included_extensions:
shutil.copytree(os.path.join("extensions",extension), os.path.join("dist/opensesame.app/Contents/Resources/extensions/",extension))
# Copy plugins into app
for plugin in included_plugins:
shutil.copytree(os.path.join("plugins",plugin), os.path.join("dist/opensesame.app/Contents/Resources/plugins/",plugin))
# Anaconda libpng version is too old for pygame (min required version is 36). Copy homebrew version instead
try:
shutil.copy('/usr/local/opt/libpng/lib/libpng16.16.dylib','dist/OpenSesame.app/Contents/Frameworks/libpng16.16.dylib')
except:
print("Could not copy newer libpng16.16.dylib")
# Remove opensesame.py
try:
os.remove("opensesame.py")
os.remove("opensesamerun.py")
except:
pass