forked from open-cogsci/OpenSesame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·201 lines (166 loc) · 4.86 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/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/>.
"""
import os
import shutil
from setuptools import setup
from libopensesame import metadata
from setup_shared import included_plugins, included_extensions
import fnmatch
# Fix a bug in the packaging of stdeb
try:
from stdeb import util
except ImportError:
pass
else:
if not hasattr(util, 'RULES_BINARY_ALL_TARGET'):
util.RULES_BINARY_ALL_TARGET = '\nbinary: binary-indep\n'
# For debian packaging, we use a slightly different version-number scheme, which
# is triggered by setting the USEDEBVERSION environment variable.
if 'USEDEBVERSION' in os.environ and os.environ['USEDEBVERSION'] == '1':
version = metadata.deb_version
else:
version = metadata.__version__
EXCLUDE = [
u'[\\/].*',
u'*eco_alt_template.osexp',
u'*~',
u'*.pyc',
u'*.pyo',
u'*__pycache__*'
]
def is_excluded(path):
for m in EXCLUDE:
if fnmatch.fnmatch(path, m):
return True
return False
def resources():
"""
desc:
Create a list of all resource files that need to be included
returns:
A list of (target folder, filenames) tuples.
"""
l = []
for root, dirnames, filenames in os.walk(u'opensesame_resources'):
for f in filenames:
path = os.path.join(root, f)
if not is_excluded(path):
l.append((os.path.join(u'share', root), [path]))
return l
def recursive_glob(src_folder, target_folder):
"""
desc:
Recursively gets all files that are in src folder.
arguments:
src_folder: The source folder.
target_folder: The target folder.
returns:
A list of (target folder, filenames) tuples.
"""
l = []
print(src_folder)
path_list = []
for path in os.listdir(src_folder):
full_path = os.path.join(src_folder, path)
if os.path.isdir(full_path):
l += recursive_glob(full_path, os.path.join(target_folder, path))
continue
if is_excluded(full_path):
continue
print(u'\t%s' % full_path)
path_list.append(full_path)
l.append( (os.path.join(u'share', target_folder), path_list) )
return l
def plugins(included, _type=u'plugins'):
"""
desc:
Create a list of all plugin files that need to be included.
arguments:
included: A list of included plugin names.
_type: The plugin type, i.e. 'plugins' or 'extensions'.
returns:
A list of (target folder, filenames) tuples.
"""
l = []
for plugin in os.listdir(u'opensesame_%s' % _type):
if plugin in included:
folder = os.path.join(u'opensesame_%s' % _type, plugin)
l += recursive_glob(folder, folder)
return l
def data_files():
return [(u"share/icons/hicolor/scalable/apps", [u"mime/opensesame.svg"])] + \
plugins(included=included_plugins, _type=u'plugins') + \
plugins(included=included_extensions, _type=u'extensions') + \
resources()
# Temporarily create README.txt
shutil.copy(u'readme.md', u'README.txt')
setup(name=u"python-opensesame",
version=version,
description=u"A graphical experiment builder for the social sciences",
author=u"Sebastiaan Mathot",
author_email=u"s.mathot@cogsci.nl",
url=u"http://osdoc.cogsci.nl/",
scripts=['opensesame', 'opensesamerun'],
include_package_data=False,
packages=[
"openexp",
"openexp._canvas",
"openexp._keyboard",
"openexp._mouse",
"openexp._sampler",
"openexp._coordinates",
"openexp._clock",
"openexp._log",
"openexp._color",
"libopensesame",
"libopensesame.osexpfile",
"libopensesame.widgets",
"libopensesame.widgets.themes",
"libopensesame.sketchpad_elements",
"libqtopensesame",
"libqtopensesame.extensions",
"libqtopensesame.actions",
"libqtopensesame.dialogs",
"libqtopensesame.items",
"libqtopensesame.misc",
"libqtopensesame.runners",
"libqtopensesame.widgets",
"libqtopensesame.validators",
"libqtopensesame.sketchpad_elements",
"libqtopensesame._input",
"libqtopensesame.console",
],
data_files=data_files(),
install_requires=[
'python-qprogedit',
'python-qdatamatrix',
'python-pseudorandom',
'python-qnotifications',
'python-fileinspector',
'PyYAML',
'webcolors',
],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
],
)
# Clean up temporary readme
os.remove(u'README.txt')