root/releases/pkgcore-checks/0.3.4/setup.py @ ferringb%2540gmail.com-20070219204925-yhc029z0rd7usm8d

Revision ferringb%2540gmail.com-20070219204925-yhc029z0rd7usm8d, 3.2 kB (checked in by Brian Harring <ferringb@…>, 21 months ago)

add NEWS, AUTHORS, and COPYING into the tarball

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
71    def get_file_list(self):
72        sdist.get_file_list(self)
73        self.filelist.append("NEWS")
74        self.filelist.append("AUTHORS")
75        self.filelist.append("COPYING")
76
77    def run(self):
78        print "regenning ChangeLog"
79        os.system("bzr log > ChangeLog")
80        sdist.run(self)
81
82packages = []
83for root, dirs, files in os.walk('pkgcore_checks'):
84    if '__init__.py' in files:
85        package = root.replace(os.path.sep, '.')
86        print 'adding package %r' % (package,)
87        packages.append(package)
88
89try:
90    os.unlink("MANIFEST")
91except OSError:
92    pass
93
94from pkgcore_checks import __version__
95setup(
96    name="pkgcore-checks",
97    version=__version__,
98    license="GPL2",
99    author="Brian Harring",
100    author_email="ferringb@gmail.com",
101    description="pkgcore based ebuild checks- repoman replacement",
102    packages=packages,
103    py_modules=[
104        'pkgcore.plugins.pcheck_config',
105        'pkgcore.plugins.pcheck_configurables',
106        ],
107    scripts=["pcheck", "replay-pcheck-stream"],
108    cmdclass={"sdist":mysdist, "test":test}
109)
Note: See TracBrowser for help on using the browser.