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.
10 Standard setup script.
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
):
26 Master setup build command to subclass from.
31 def initialize_options(self
):
33 Setup the current dir.
35 self
._dir
= os
.getcwd()
37 def finalize_options(self
):
44 class TestCommand(_SetupBuildCommand
):
46 Executes tests from setup.
49 description
= "Run unittests inline"
55 self
._run
(os
.path
.normpath(os
.path
.abspath(
56 os
.path
.join('buildbot', 'test'))))
58 def _run(self
, test_loc
):
60 Executes the test step.
62 @param test_loc: location of test module
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
)
81 class SdistTestCommand(TestCommand
):
83 Runs unittests from the sdist output.
86 description
= "Run unittests from inside an sdist distribution"
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
96 if os
.path
.exists('dist'):
97 for root
, dirs
, files
in os
.walk('dist', topdown
=False):
99 os
.remove(os
.path
.join(root
, name
))
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')
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
126 class install_data_twisted(install_data
):
127 """make sure data files are installed in package.
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
)
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
153 scripts
= ["bin/buildbot"]
154 if sys
.platform
== "win32":
155 scripts
.append("contrib/windows/buildbot.bat")
156 scripts
.append("contrib/windows/buildbot_service.py")
159 for f
in os
.listdir("buildbot/test/mail"):
162 if re
.search(r
'\.\d+$', f
):
163 testmsgs
.append("buildbot/test/mail/%s" % f
)
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?
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",
191 "buildbot.steps.package",
192 "buildbot.steps.package.rpm",
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"]),
211 'cmdclass': {'install_data': install_data_twisted
,
213 'sdist_test': SdistTestCommand
},
217 # If setuptools is installed, then we'll add setuptools-specific arguments
223 setup_args
['install_requires'] = ['twisted >= 2.0.0']
226 'buildbot = buildbot.scripts.runner:run'],