Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-07-12 21:34:20 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-07-12 22:06:54 (GMT)
commita188dac0527803edb46eabce04100f1c741a96f3 (patch)
tree02dbf117301b5ef8e8fae7da59bce8c56496cf45 /setup.py
parent625f9bb52eda3215d82d1b76ec6a806459f321ce (diff)
parent539c3f2c7d5316ea64a00dd89fc94b97f2a69fdc (diff)
repackage of tutorius using distutils
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..93471b5
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+from distutils.core import setup, Command
+from os.path import splitext, basename, join as pjoin, walk
+import os, sys
+import glob
+from unittest import TestLoader, TextTestRunner, TestSuite
+
+class TestCommand(Command):
+ user_options = [('coverage',
+ None,
+ 'enable code coverage reporting'),
+ ('prefix=',
+ 'p',
+ 'set sugar installation prefix, for dependency loading'),]
+ description = 'runs tests from the test directory'
+
+ def initialize_options(self):
+ self._dir = os.getcwd()
+ self.coverage = False
+ self.prefix = None
+
+ def finalize_options(self):
+ if not self.prefix:
+ print
+ sys.exit(1)
+
+ def run(self):
+ '''
+ Finds all the tests modules in tests/, and runs them.
+ '''
+ prefix = os.path.join(self.prefix,'lib',
+ 'python%d.%d'%sys.version_info[:2],
+ 'site-packages')
+ sys.path.insert(1, prefix)
+ if self.coverage:
+ import coverage
+ coverage.erase()
+ coverage.start()
+
+ loader = TestLoader()
+ suite = TestSuite()
+ skipped = file('tests/skip', 'r').read().split('\n')
+ for t in glob.glob(pjoin(self._dir, 'tests', '*.py')):
+ if not t.endswith('__init__.py') and basename(t) not in skipped:
+ modname = '.'.join(['tests', splitext(basename(t))[0]])
+ mod = __import__(modname, {'sys':sys}, fromlist=[modname])
+ print "loading %s" % modname
+ suite.addTest(loader.loadTestsFromModule(mod))
+ else:
+ print "skipping %s" % t
+
+ t = TextTestRunner(verbosity = 1)
+ t.run(suite)
+ if self.coverage:
+ coverage.stop()
+ sources = []
+ os.path.walk(os.path.join(prefix,'sugar','tutorius'),
+ self._listsources,
+ sources)
+ coverage.report(sources)
+ coverage.erase()
+
+ def _listsources(self, arg, dirname, fnames):
+ fnames = filter(lambda x:x.endswith('.py'), fnames)
+ for name in fnames:
+ arg.append(pjoin(dirname, name))
+
+setup(name='Tutorius',
+ version='0.0',
+ description='Interactive tutor and Tutorial creator',
+ maintainer='Simon Poirier',
+ maintainer_email='simpoir@gmail.com',
+ author='Tutorius team',
+ author_email='sugar-narratives@googlegroups.com',
+ url='http://tutorius.org',
+ license='GPLv3',
+ packages=[
+ 'sugar.tutorius',
+ 'sugar.tutorius.uam',
+ 'sugar.tutorius.addons',
+ 'sugar.graphics',
+ 'sugar.activity',
+ ],
+ package_dir={'sugar': 'toolkitfix',
+ 'sugar.tutorius': 'tutorius',
+ 'sugar.tutorius.addons': 'addons',
+ },
+ cmdclass = {'test': TestCommand},
+ data_files=[('share/icons/sugar/scalable/actions', glob.glob('data/icons/*.svg')),]
+ )
+
+# vim: set et sw=4 sts=4 ts=4: