root/releases/pkgcore-checks/0.2/setup.py @ ferringb%2540gmail.com-20070122100033-rnrcboo17eo0zce0

Revision ferringb%2540gmail.com-20070122100033-rnrcboo17eo0zce0, 2.9 kB (checked in by Brian Harring <ferringb@…>, 22 months ago)

make test run verbose

Line 
1# Copyright: 2006 Brian Harring <ferringb@gmail.com>
2# License: GPL2
3
4from distutils.core import setup, Command
5from distutils.command.sdist import sdist
6import os, unittest
7
8class TestLoader(unittest.TestLoader):
9
10    """Test loader that knows how to recurse packages."""
11
12    def loadTestsFromModule(self, module):
13        """Recurses if module is actually a package."""
14        paths = getattr(module, '__path__', None)
15        tests = [unittest.TestLoader.loadTestsFromModule(self, module)]
16        if paths is None:
17            # Not a package.
18            return tests[0]
19        for path in paths:
20            for child in os.listdir(path):
21                if (child != '__init__.py' and child.endswith('.py') and
22                    child.startswith('test')):
23                    # Child module.
24                    childname = '%s.%s' % (module.__name__, child[:-3])
25                else:
26                    childpath = os.path.join(path, child)
27                    if not os.path.isdir(childpath):
28                        continue
29                    if not os.path.exists(os.path.join(childpath,
30                                                       '__init__.py')):
31                        continue
32                    # Subpackage.
33                    childname = '%s.%s' % (module.__name__, child)
34                tests.append(self.loadTestsFromName(childname))
35        return self.suiteClass(tests)
36
37
38testLoader = TestLoader()
39
40
41class test(Command):
42
43    """Run our unit tests in a built copy.
44
45    Based on code from setuptools.
46    """
47
48    user_options = []
49
50    def initialize_options(self):
51        # Options? What options?
52        pass
53
54    def finalize_options(self):
55        # Options? What options?
56        pass
57
58    def run(self):
59        build_ext = self.reinitialize_command('build_ext')
60        build_ext.inplace = True
61        self.run_command('build_ext')
62        # Somewhat hackish: this calls sys.exit.
63        unittest.main('pkgcore_checks.test', argv=['setup.py', '-v'],
64            testLoader=testLoader)
65
66
67class mysdist(sdist):
68    default_format = dict(sdist.default_format)
69    default_format["posix"] = "bztar"
70    def run(self):
71        print "regenning ChangeLog"
72        os.system("bzr log > ChangeLog")
73        sdist.run(self)
74
75packages = []
76for root, dirs, files in os.walk('pkgcore_checks'):
77    if '__init__.py' in files:
78        package = root.replace(os.path.sep, '.')
79        print 'adding package %r' % (package,)
80        packages.append(package)
81
82try:
83    os.unlink("MANIFEST")
84except OSError:
85    pass
86
87from pkgcore_checks import __version__
88setup(
89    name="pkgcore-checks",
90    version=__version__,
91    license="GPL2",
92    author="Brian Harring",
93    author_email="ferringb@gmail.com",
94    description="pkgcore based ebuild checks- repoman replacement",
95    packages=packages,
96    py_modules=[
97        'pkgcore.plugins.pcheck_config',
98        'pkgcore.plugins.pcheck_configurables',
99        ],
100    scripts=["pcheck"],
101    cmdclass={"sdist":mysdist, "test":test}
102)
Note: See TracBrowser for help on using the browser.