(closes #574) don't use keyword arguments to List.sort
[buildbot.git] / setup.py
blob61748a6e903a882a44e539bbd3e141b4dd58f706
1 #!/usr/bin/env python
3 # This software may be freely redistributed under the terms of the GNU
4 # general public license.
6 # You should have received a copy of the GNU General Public License
7 # along with this program; if not, write to the Free Software
8 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
9 """
10 Standard setup script.
11 """
13 import sys
14 import os
15 import re
17 from distutils.core import setup, Command
18 from buildbot import version
20 # Path: twisted!cvstoys!buildbot
21 from distutils.command.install_data import install_data
24 class _SetupBuildCommand(Command):
25 """
26 Master setup build command to subclass from.
27 """
29 user_options = []
31 def initialize_options(self):
32 """
33 Setup the current dir.
34 """
35 self._dir = os.getcwd()
37 def finalize_options(self):
38 """
39 Required.
40 """
41 pass
44 class TestCommand(_SetupBuildCommand):
45 """
46 Executes tests from setup.
47 """
49 description = "Run unittests inline"
51 def run(self):
52 """
53 Public run method.
54 """
55 self._run(os.path.normpath(os.path.abspath(
56 os.path.join('buildbot', 'test'))))
58 def _run(self, test_loc):
59 """
60 Executes the test step.
62 @param test_loc: location of test module
63 @type test_loc: str
64 """
65 from twisted.scripts.trial import run
67 # Mimick the trial script by adding the path as the last arg
68 sys.argv.append(test_loc)
70 # No superuser should execute tests
71 if hasattr(os, "getuid") and os.getuid() == 0:
72 raise SystemExit('Do not test as a superuser! Exiting ...')
74 # Add the current dir to path and pull it all together
75 sys.path.insert(0, os.path.curdir)
76 sys.path[:] = map(os.path.abspath, sys.path)
77 # GO!
78 run()
81 class SdistTestCommand(TestCommand):
82 """
83 Runs unittests from the sdist output.
84 """
86 description = "Run unittests from inside an sdist distribution"
88 def run(self):
89 """
90 Interesting magic to get a source dist and running trial on it.
92 NOTE: there is magic going on here! If you know a better way feel
93 free to update it.
94 """
95 # Clean out dist/
96 if os.path.exists('dist'):
97 for root, dirs, files in os.walk('dist', topdown=False):
98 for name in files:
99 os.remove(os.path.join(root, name))
100 for name in dirs:
101 os.rmdir(os.path.join(root, name))
102 # Import setup making it as if we ran setup.py with the sdist arg
103 sys.argv.append('sdist')
104 import setup
105 try:
106 # attempt to extract the sdist data
107 from gzip import GzipFile
108 from tarfile import TarFile
109 # We open up the gzip as well as using the first item as the sdist
110 gz = GzipFile(os.path.join('dist', os.listdir('dist')[0]))
111 tf = TarFile(fileobj=gz)
112 # Make the output dir and generate the extract path
113 os.mkdir(os.path.join('dist', 'sdist_test'))
114 ex_path = os.path.join('dist', 'sdist_test',
115 tf.getmembers()[0].name, 'buildbot', 'test')
116 # Extract the data and run tests
117 print "Extracting to %s" % ex_path
118 tf.extractall(os.path.join('dist', 'sdist_test'))
119 print "Executing tests ..."
120 self._run(os.path.normpath(os.path.abspath(ex_path)))
121 except IndexError, ie:
122 # We get called twice and the IndexError is OK
123 pass
126 class install_data_twisted(install_data):
127 """make sure data files are installed in package.
128 this is evil.
129 copied from Twisted/setup.py.
132 def finalize_options(self):
133 self.set_undefined_options('install',
134 ('install_lib', 'install_dir'),
136 install_data.finalize_options(self)
138 long_description="""
139 The BuildBot is a system to automate the compile/test cycle required by
140 most software projects to validate code changes. By automatically
141 rebuilding and testing the tree each time something has changed, build
142 problems are pinpointed quickly, before other developers are
143 inconvenienced by the failure. The guilty developer can be identified
144 and harassed without human intervention. By running the builds on a
145 variety of platforms, developers who do not have the facilities to test
146 their changes everywhere before checkin will at least know shortly
147 afterwards whether they have broken the build or not. Warning counts,
148 lint checks, image size, compile time, and other build parameters can
149 be tracked over time, are more visible, and are therefore easier to
150 improve.
153 scripts = ["bin/buildbot"]
154 if sys.platform == "win32":
155 scripts.append("contrib/windows/buildbot.bat")
156 scripts.append("contrib/windows/buildbot_service.py")
158 testmsgs = []
159 for f in os.listdir("buildbot/test/mail"):
160 if f.endswith("~"):
161 continue
162 if re.search(r'\.\d+$', f):
163 testmsgs.append("buildbot/test/mail/%s" % f)
165 setup_args = {
166 'name': "buildbot",
167 'version': version,
168 'description': "BuildBot build automation system",
169 'long_description': long_description,
170 'author': "Brian Warner",
171 'author_email': "warner-buildbot@lothar.com",
172 'maintainer': "Dustin J. Mitchell",
173 'maintainer_email': "dustin@v.igoro.us",
174 'url': "http://buildbot.net/",
175 'license': "GNU GPL",
176 # does this classifiers= mean that this can't be installed on 2.2/2.3?
177 'classifiers': [
178 'Development Status :: 5 - Production/Stable',
179 'Environment :: No Input/Output (Daemon)',
180 'Environment :: Web Environment',
181 'Intended Audience :: Developers',
182 'License :: OSI Approved :: GNU General Public License (GPL)',
183 'Topic :: Software Development :: Build Tools',
184 'Topic :: Software Development :: Testing',
187 'packages': ["buildbot",
188 "buildbot.status", "buildbot.status.web",
189 "buildbot.changes",
190 "buildbot.steps",
191 "buildbot.steps.package",
192 "buildbot.steps.package.rpm",
193 "buildbot.process",
194 "buildbot.clients",
195 "buildbot.slave",
196 "buildbot.scripts",
197 "buildbot.test",
199 'data_files': [("buildbot", ["buildbot/buildbot.png"]),
200 ("buildbot/clients", ["buildbot/clients/debug.glade"]),
201 ("buildbot/status/web",
202 ["buildbot/status/web/classic.css",
203 "buildbot/status/web/index.html",
204 "buildbot/status/web/robots.txt",
206 ("buildbot/scripts", ["buildbot/scripts/sample.cfg"]),
207 ("buildbot/test/mail", testmsgs),
208 ("buildbot/test/subdir", ["buildbot/test/subdir/emit.py"]),
210 'scripts': scripts,
211 'cmdclass': {'install_data': install_data_twisted,
212 'test': TestCommand,
213 'sdist_test': SdistTestCommand},
216 try:
217 # If setuptools is installed, then we'll add setuptools-specific arguments
218 # to the setup args.
219 import setuptools
220 except ImportError:
221 pass
222 else:
223 setup_args['install_requires'] = ['twisted >= 2.0.0']
224 entry_points={
225 'console_scripts': [
226 'buildbot = buildbot.scripts.runner:run'],
229 setup(**setup_args)
231 # Local Variables:
232 # fill-column: 71
233 # End: