forked from indico/indico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
536 lines (420 loc) · 18.9 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# -*- coding: utf-8 -*-
##
##
## This file is part of Indico
## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN)
##
## Indico 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.
##
## Indico 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 Indico. If not, see <http://www.gnu.org/licenses/>.
# Autoinstalls setuptools if the user doesn't have them already
import ez_setup
ez_setup.use_setuptools()
import os
import getpass
import re
import shutil
import sys
from distutils.sysconfig import get_python_lib, get_python_version
from distutils.cmd import Command
from distutils.command import bdist
from indico.util import i18n
import pkg_resources
from setuptools.command import develop, sdist, bdist_egg, easy_install, test
from setuptools import setup, find_packages, findall
try:
from babel.messages import frontend as babel
BABEL_PRESENT = True
except ImportError:
BABEL_PRESENT = False
DEPENDENCY_URLS = ["http://indico-software.org/wiki/Admin/Installation/IndicoExtras"]
class vars(object):
'''Variable holder.'''
packageDir = None
versionVal = 'None'
accessuser = None
accessgroup = None
dbInstalledBySetupPy = False
binDir = None
documentationDir = None
configurationDir = None
htdocsDir = None
### Methods required by setup() ##############################################
def read_requirements_file(fname):
with open(fname, 'r') as f:
return [dep.strip() for dep in f.readlines() if not (dep.startswith('-') or '://' in dep)]
def _generateDataPaths(x):
dataFilesDict = {}
for (baseDstDir, srcDir) in x:
for f in findall(srcDir):
dst_dir = os.path.join(baseDstDir,
os.path.relpath(os.path.dirname(f), srcDir))
if dst_dir not in dataFilesDict:
dataFilesDict[dst_dir] = []
dataFilesDict[dst_dir].append(f)
dataFiles = []
for k, v in dataFilesDict.items():
dataFiles.append((k, v))
return dataFiles
def _getInstallRequires():
"""Returns external packages required by Indico
These are the ones needed for runtime."""
return read_requirements_file(os.path.join(os.path.dirname(__file__), 'requirements.txt'))
def _versionInit():
"""Retrieves the version number from indico/MaKaC/__init__.py and returns it"""
from indico.MaKaC import __version__
v = __version__
print 'Indico %s' % v
return v
### Commands ###########################################################
class sdist_indico(sdist.sdist):
user_options = (sdist.sdist.user_options +
[('version=', None, 'version to distribute')])
version = 'dev'
def run(self):
sdist.sdist.run(self)
def _bdist_indico(dataFiles):
class bdist_indico(bdist.bdist):
def run(self):
compileAllLanguages(self)
bdist.bdist.run(self)
bdist_indico.dataFiles = dataFiles
return bdist_indico
def _bdist_egg_indico(dataFiles):
class bdist_egg_indico(bdist_egg.bdist_egg):
def run(self):
compileAllLanguages(self)
bdist_egg.bdist_egg.run(self)
bdist_egg_indico.dataFiles = dataFiles
return bdist_egg_indico
class develop_indico(develop.develop):
def run(self):
develop.develop.run(self)
# create symlink to legacy MaKaC dir
# this is so that the ".egg-link" created by the "develop" command works
if sys.platform in ["linux2", "darwin"] and not os.path.exists('MaKaC'):
os.symlink('indico/MaKaC', 'MaKaC')
# install dev dependencies
env = pkg_resources.Environment()
easy_install.main(read_requirements_file(os.path.join(os.path.dirname(__file__), 'requirements.dev.txt')))
env.scan()
class develop_config(develop_indico):
description = "prepares the current directory for Indico development"
user_options = (develop.develop.user_options +
[('www-uid=', None, "Set user for cache/log/db (typically apache user)"),
('www-gid=', None, "Set group for cache/log/db (typically apache group)"),
('http-port=', None, "Set port used by HTTP server"),
('https-port=', None, "Set port used by HTTP server in HTTPS mode"),
('zodb-port=', None, "Set port used by ZODB"),
('smtp-port=', None, "Set port used for SMTP (e-mail sending)"),
('use-apache', None, "Use apache (will chmod directories accordingly)")])
www_uid = None
www_gid = None
http_port = 8000
https_port = 8443
zodb_port = 9675
use_apache = False
smtp_port = 8025
def run(self):
# dependencies, links, etc...
develop_indico.run(self)
local = 'etc/indico.conf'
if os.path.exists(local):
print 'Upgrading existing etc/indico.conf...'
else:
print 'Creating new etc/indico.conf..'
shutil.copy('etc/indico.conf.sample', local)
upgrade_indico_conf(local, 'etc/indico.conf.sample', {
'BaseURL': 'http://localhost:{0}'.format(self.http_port),
'BaseSecureURL': 'https://localhost:{0}'.format(self.https_port),
'DBConnectionParams': ("localhost", int(self.zodb_port)),
'SmtpServer': ("localhost", int(self.smtp_port))
})
for f in [x for x in ('etc/zdctl.conf', 'etc/zodb.conf', 'etc/logging.conf') if not os.path.exists(x)]:
shutil.copy('%s.sample' % f, f)
print """\nIndico needs to store some information in the filesystem (database, cache, temporary files, logs...)
Please specify the directory where you'd like it to be placed.
(Note that putting it outside of your sourcecode tree is recommended)"""
prefixDirDefault = os.path.dirname(os.getcwd())
prefixDir = raw_input('Full path [%s]: ' % prefixDirDefault).strip()
if prefixDir == '':
prefixDir = prefixDirDefault
directories = dict((d, os.path.join(prefixDir, d)) for d in
['db', 'log', 'tmp', 'cache', 'archive'])
print 'Creating directories...',
for d in directories.values():
if not os.path.exists(d):
os.makedirs(d)
print 'Done!'
# add existing dirs
directories.update(dict((d, os.path.join(os.getcwd(), 'indico', d)) for d in ['htdocs', 'bin', 'etc', 'doc']))
self._update_conf_dir_paths(local, directories)
# avoid modifying the htdocs folder permissions (it brings problems with git)
directories.pop('htdocs')
from MaKaC.consoleScripts.installBase import _databaseText, _findApacheUserGroup, _checkDirPermissions, \
_updateDbConfigFiles, _updateMaKaCEggCache
user = getpass.getuser()
sourcePath = os.getcwd()
if self.use_apache:
# find the apache user/group
user, group = _findApacheUserGroup(self.www_uid, self.www_gid)
_checkDirPermissions(directories, dbInstalledBySetupPy=directories['db'], accessuser=user, accessgroup=group)
_updateDbConfigFiles(os.path.join(sourcePath, 'etc'),
db=directories['db'],
log=directories['log'],
tmp=directories['tmp'],
port=self.zodb_port,
uid=user)
_updateMaKaCEggCache(os.path.join(os.path.dirname(__file__), 'indico', 'MaKaC', '__init__.py'),
directories['tmp'])
compileAllLanguages(self)
print '''
%s
''' % _databaseText('etc')
def _update_conf_dir_paths(self, filePath, dirs):
fdata = open(filePath).read()
for dir in dirs.items():
d = dir[1].replace("\\", "/") # For Windows users
fdata = re.sub('\/opt\/indico\/%s' % dir[0], d, fdata)
open(filePath, 'w').write(fdata)
class test_indico(test.test):
"""
Test command for Indico
"""
description = "Test Suite Framework"
user_options = (test.test.user_options + [('specify=', None, "Use nosetests style (file.class:testcase)"),
('coverage', None, "Output coverage report in html"),
('unit', None, "Run only Unit tests"),
('functional', None, "Run only Functional tests"),
('pylint', None, "Run python source analysis"),
('jsunit', None, "Run js unit tests"),
('jslint', None, "Run js source analysis"),
('jscoverage', None, "Output coverage report in html for js"),
('jsspecify=', None, "Use js-test-driver style (TestCaseName.testName)"),
('log=', None, "Log to console, using specified level"),
('browser=', None, "Browser to use for functional tests"),
('mode=', None, "Mode to use for functional tests"),
('server-url=', None, "Server URL to use for functional tests"),
('xml', None, "XML output"),
('html', None, "Make an HTML report (when possible)"),
('record', None, "Record tests (for --functional)"),
('silent', None, "Don't output anything in the console, just generate the report"),
('clean-shutdown', None,
"Do not kill this script right after the tests finished without waiting for db shutdown.")])
boolean_options = []
specify = None
coverage = False
unit = False
functional = False
browser = None
pylint = False
jsunit = False
jslint = False
jscoverage = False
jsspecify = None
silent = False
mode = None
server_url = None
clean_shutdown = False
html = False
record = False
log = False
xml = False
def _wrap(self, func, *params):
def wrapped():
self.res = func(*params)
self.with_project_on_sys_path(wrapped)
return self.res
def finalize_options(self):
testsToRun = []
allTests = ['unit', 'functional']
for testType in allTests:
if getattr(self, testType):
testsToRun.append(testType)
if self.jsspecify and 'jsunit' not in testsToRun:
testsToRun.append('jsunit')
if not testsToRun:
testsToRun = allTests
self.testsToRun = testsToRun
def run(self):
if self.distribution.install_requires:
self.distribution.fetch_build_eggs(self.distribution.install_requires)
if self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require)
from indico.tests import TestManager
options = {'silent': self.silent,
'killself': not self.clean_shutdown,
'html': self.html,
'browser': self.browser,
'mode': self.mode,
'specify': self.specify,
'coverage': self.coverage,
'record': self.record,
'server_url': self.server_url,
'log': self.log,
'xml': self.xml}
# get only options that are active
options = dict((k, v) for (k, v) in options.iteritems() if v)
manager = TestManager()
result = self._wrap(manager.main, self.testsToRun, options)
sys.exit(result)
def download(self, url, path):
"""Copy the contents of a file from a given URL
to a local file.
"""
import urllib
webFile = urllib.urlopen(url)
localFile = open(os.path.join(path, url.split('/')[-1]), 'w')
localFile.write(webFile.read())
webFile.close()
localFile.close()
def unzip(self, zipPath, inZipPath, targetFile):
"""extract the needed file from zip and then delete the zip"""
import zipfile
try:
zfobj = zipfile.ZipFile(zipPath)
outfile = open(targetFile, 'wb')
outfile.write(zfobj.read(inZipPath))
outfile.flush()
outfile.close()
#delete zip file
os.unlink(zipPath)
except NameError, e:
print e
class egg_filename(Command):
description = "Get the file name of the generated egg"
user_options = []
boolean_options = []
def initialize_options(self):
pass
def finalize_options(self):
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
self.egg_info = ei_cmd.egg_info
basename = pkg_resources.Distribution(
None, None, ei_cmd.egg_name, ei_cmd.egg_version,
get_python_version(),
self.distribution.has_ext_modules() and pkg_utils.get_build_platform).egg_name()
print basename
def run(self):
pass
if __name__ == '__main__':
# Always load source from the current folder
sys.path = [os.path.abspath('indico')] + sys.path
#PWD_INDICO_CONF = 'etc/indico.conf'
#if not os.path.exists(PWD_INDICO_CONF):
# shutil.copy('etc/indico.conf.sample', PWD_INDICO_CONF)
from MaKaC.consoleScripts.installBase import *
#Dirty trick: For running tests, we need to load all the modules and get rid of unnecessary outputs
tempLoggingDir = None
if 'test' in sys.argv:
import logging
import tempfile
tempLoggingDir = tempfile.mkdtemp()
logging.basicConfig(filename=os.path.join(tempLoggingDir, 'logging'),
level=logging.DEBUG)
setIndicoInstallMode(False)
else:
setIndicoInstallMode(True)
x = vars()
x.packageDir = os.path.join(get_python_lib(), 'MaKaC')
x.binDir = 'bin'
x.documentationDir = 'doc'
x.configurationDir = 'etc'
x.htdocsDir = 'htdocs'
dataFiles = _generateDataPaths((('bin', 'bin'), ('doc', 'doc'), ('etc', 'etc'), ('migrations', 'migrations')))
foundPackages = list('MaKaC.%s' % pkg for pkg in
find_packages(where='indico/MaKaC'))
foundPackages.append('MaKaC')
foundPackages.append('htdocs')
# add our namespace package
foundPackages += list('indico.%s' % pkg for pkg in
find_packages(where='indico',
exclude=['htdocs*', 'MaKaC*']))
foundPackages.append('indico')
cmdclass = {'sdist': sdist_indico,
'bdist': _bdist_indico(dataFiles),
'bdist_egg': _bdist_egg_indico(dataFiles),
'develop_config': develop_config,
'develop': develop_indico,
'test': test_indico,
'egg_filename': egg_filename
}
if BABEL_PRESENT:
for cmdname in ['init_catalog', 'extract_messages', 'compile_catalog', 'update_catalog']:
cmdclass['%s_js' % cmdname] = getattr(babel, cmdname)
cmdclass['compile_catalog_js'] = i18n.generate_messages_js
setup(name="indico",
cmdclass=cmdclass,
version=_versionInit(),
description="Indico is a full-featured conference lifecycle management and meeting/lecture scheduling tool",
author="Indico Team",
author_email="[email protected]",
url="http://indico-software.org",
download_url="http://indico-software.org/wiki/Releases/Indico1.2",
platforms=["any"],
long_description="Indico allows you to schedule conferences, from single talks to complex meetings with "
"sessions and contributions. It also includes an advanced user delegation mechanism, "
"allows paper reviewing, archival of conference information and electronic proceedings",
license="http://www.gnu.org/licenses/gpl-3.0.txt",
entry_points="""
[console_scripts]
indico_scheduler = indico.modules.scheduler.daemon_script:main
indico_initial_setup = MaKaC.consoleScripts.indicoInitialSetup:main
indico_ctl = MaKaC.consoleScripts.indicoCtl:main
indico_livesync = indico.ext.livesync.console:main
indico = indico.cli.manage:main
[indico.ext_types]
statistics = indico.ext.statistics
Collaboration = MaKaC.plugins.Collaboration
InstantMessaging = MaKaC.plugins.InstantMessaging
EPayment = MaKaC.plugins.EPayment
livesync = indico.ext.livesync
importer = indico.ext.importer
calendaring = indico.ext.calendaring
search = indico.ext.search
[indico.ext]
statistics.piwik = indico.ext.statistics.piwik
Collaboration.EVO = MaKaC.plugins.Collaboration.EVO
Collaboration.WebEx = MaKaC.plugins.Collaboration.WebEx
Collaboration.Vidyo = MaKaC.plugins.Collaboration.Vidyo
Collaboration.CERNMCU = MaKaC.plugins.Collaboration.CERNMCU
Collaboration.RecordingManager = MaKaC.plugins.Collaboration.RecordingManager
Collaboration.RecordingRequest = MaKaC.plugins.Collaboration.RecordingRequest
Collaboration.WebcastRequest = MaKaC.plugins.Collaboration.WebcastRequest
EPayment.payPal = MaKaC.plugins.EPayment.payPal
EPayment.worldPay = MaKaC.plugins.EPayment.worldPay
EPayment.yellowPay = MaKaC.plugins.EPayment.yellowPay
EPayment.skipjack = MaKaC.plugins.EPayment.skipjack
importer.invenio = indico.ext.importer.invenio
importer.dummy = indico.ext.importer.dummy
InstantMessaging.XMPP = MaKaC.plugins.InstantMessaging.XMPP
livesync.invenio = indico.ext.livesync.invenio
livesync.cern_search = indico.ext.livesync.cern_search
calendaring.outlook = indico.ext.calendaring.outlook
search.invenio = indico.ext.search.invenio
""",
zip_safe=False,
packages=foundPackages,
package_dir={'indico': 'indico',
'htdocs': os.path.join('indico', 'htdocs'),
'MaKaC': os.path.join('indico', 'MaKaC')},
package_data={'indico': ['*.*']},
include_package_data=True,
namespace_packages=['indico', 'indico.ext'],
install_requires=_getInstallRequires(),
tests_require=['nose', 'rednose', 'twill', 'selenium', 'figleaf', 'contextlib2'],
data_files=dataFiles,
dependency_links=DEPENDENCY_URLS
)
#delete the temp folder used for logging
if 'test' in sys.argv:
shutil.rmtree(tempLoggingDir)