3 # This file is part of Buildbot. Buildbot is free software: you can
4 # redistribute it and/or modify it under the terms of the GNU General Public
5 # License as published by the Free Software Foundation, version 2.
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # You should have received a copy of the GNU General Public License along with
13 # this program; if not, write to the Free Software Foundation, Inc., 51
14 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 # Copyright Buildbot Team Members
19 Standard setup script.
27 from distutils
.core
import setup
, Command
28 from buildbot
import version
30 from distutils
.command
.install_data
import install_data
31 from distutils
.command
.sdist
import sdist
34 """Generate a pair of (directory, file-list) for installation.
37 'e' -- A glob pattern"""
39 return (d
, [f
for f
in glob
.glob('%s/%s'%(d
, e
)) if os
.path
.isfile(f
)])
41 class _SetupBuildCommand(Command
):
43 Master setup build command to subclass from.
48 def initialize_options(self
):
50 Setup the current dir.
52 self
._dir
= os
.getcwd()
54 def finalize_options(self
):
61 class TestCommand(_SetupBuildCommand
):
63 Executes tests from setup.
66 description
= "Run unittests inline"
72 self
._run
(os
.path
.normpath(os
.path
.abspath(
73 os
.path
.join('buildbot', 'test'))))
75 def _run(self
, test_loc
):
77 Executes the test step.
79 @param test_loc: location of test module
82 from twisted
.scripts
.trial
import run
84 # Mimick the trial script by adding the path as the last arg
85 sys
.argv
.append(test_loc
)
87 # No superuser should execute tests
88 if hasattr(os
, "getuid") and os
.getuid() == 0:
89 raise SystemExit('Do not test as a superuser! Exiting ...')
91 # Add the current dir to path and pull it all together
92 sys
.path
.insert(0, os
.path
.curdir
)
93 sys
.path
[:] = map(os
.path
.abspath
, sys
.path
)
98 class SdistTestCommand(TestCommand
):
100 Runs unittests from the sdist output.
103 description
= "Run unittests from inside an sdist distribution"
107 Interesting magic to get a source dist and running trial on it.
109 NOTE: there is magic going on here! If you know a better way feel
113 if os
.path
.exists('dist'):
114 for root
, dirs
, files
in os
.walk('dist', topdown
=False):
116 os
.remove(os
.path
.join(root
, name
))
118 os
.rmdir(os
.path
.join(root
, name
))
119 # Import setup making it as if we ran setup.py with the sdist arg
120 sys
.argv
.append('sdist')
121 import setup
#@Reimport @UnresolvedImport @UnusedImport
123 # attempt to extract the sdist data
124 from gzip
import GzipFile
125 from tarfile
import TarFile
126 # We open up the gzip as well as using the first item as the sdist
127 gz
= GzipFile(os
.path
.join('dist', os
.listdir('dist')[0]))
128 tf
= TarFile(fileobj
=gz
)
129 # Make the output dir and generate the extract path
130 os
.mkdir(os
.path
.join('dist', 'sdist_test'))
131 ex_path
= os
.path
.join('dist', 'sdist_test',
132 tf
.getmembers()[0].name
, 'buildbot', 'test')
133 # Extract the data and run tests
134 print "Extracting to %s" % ex_path
135 tf
.extractall(os
.path
.join('dist', 'sdist_test'))
136 print "Executing tests ..."
137 self
._run
(os
.path
.normpath(os
.path
.abspath(ex_path
)))
138 except IndexError, ie
:
139 # We get called twice and the IndexError is OK
143 class install_data_twisted(install_data
):
144 """make sure data files are installed in package.
146 copied from Twisted/setup.py.
149 def finalize_options(self
):
150 self
.set_undefined_options('install',
151 ('install_lib', 'install_dir'),
153 install_data
.finalize_options(self
)
156 install_data
.run(self
)
157 # ensure there's a buildbot/VERSION file
158 fn
= os
.path
.join(self
.install_dir
, 'buildbot', 'VERSION')
159 open(fn
, 'w').write(version
)
160 self
.outfiles
.append(fn
)
162 class our_sdist(sdist
):
164 def make_release_tree(self
, base_dir
, files
):
165 sdist
.make_release_tree(self
, base_dir
, files
)
166 # ensure there's a buildbot/VERSION file
167 fn
= os
.path
.join(base_dir
, 'buildbot', 'VERSION')
168 open(fn
, 'w').write(version
)
172 The BuildBot is a system to automate the compile/test cycle required by
173 most software projects to validate code changes. By automatically
174 rebuilding and testing the tree each time something has changed, build
175 problems are pinpointed quickly, before other developers are
176 inconvenienced by the failure. The guilty developer can be identified
177 and harassed without human intervention. By running the builds on a
178 variety of platforms, developers who do not have the facilities to test
179 their changes everywhere before checkin will at least know shortly
180 afterwards whether they have broken the build or not. Warning counts,
181 lint checks, image size, compile time, and other build parameters can
182 be tracked over time, are more visible, and are therefore easier to
186 scripts
= ["bin/buildbot"]
187 # sdist is usually run on a non-Windows platform, but the buildslave.bat file
188 # still needs to get packaged.
189 if 'sdist' in sys
.argv
or sys
.platform
== 'win32':
190 scripts
.append("contrib/windows/buildbot.bat")
191 scripts
.append("contrib/windows/buildbot_service.py")
196 'description': "BuildBot build automation system",
197 'long_description': long_description
,
198 'author': "Brian Warner",
199 'author_email': "warner-buildbot@lothar.com",
200 'maintainer': "Dustin J. Mitchell",
201 'maintainer_email': "dustin@v.igoro.us",
202 'url': "http://buildbot.net/",
203 'license': "GNU GPL",
204 # does this classifiers= mean that this can't be installed on 2.2/2.3?
206 'Development Status :: 5 - Production/Stable',
207 'Environment :: No Input/Output (Daemon)',
208 'Environment :: Web Environment',
209 'Intended Audience :: Developers',
210 'License :: OSI Approved :: GNU General Public License (GPL)',
211 'Topic :: Software Development :: Build Tools',
212 'Topic :: Software Development :: Testing',
215 'packages': ["buildbot",
216 "buildbot.status", "buildbot.status.web","buildbot.status.web.hooks",
219 "buildbot.steps.package",
220 "buildbot.steps.package.rpm",
223 "buildbot.schedulers",
226 "buildbot.db.schema",
229 "buildbot.test.fake",
230 "buildbot.test.unit",
231 "buildbot.test.util",
232 "buildbot.test.regressions",
234 'data_files': [("buildbot", ["buildbot/buildbot.png"]),
235 include("buildbot/db/schema", "*.sql"),
236 ("buildbot/clients", ["buildbot/clients/debug.glade"]),
237 ("buildbot/status/web/files",
238 ["buildbot/status/web/files/default.css",
239 "buildbot/status/web/files/bg_gradient.jpg",
240 "buildbot/status/web/files/robots.txt",
241 "buildbot/status/web/files/favicon.ico",
243 include("buildbot/status/web/templates", '*.html'),
244 include("buildbot/status/web/templates", '*.xml'),
245 ("buildbot/scripts", ["buildbot/scripts/sample.cfg"]),
248 'cmdclass': {'install_data': install_data_twisted
,
250 'sdist_test': SdistTestCommand
,
254 # set zip_safe to false to force Windows installs to always unpack eggs
255 # into directories, which seems to work better --
256 # see http://buildbot.net/trac/ticket/907
257 if sys
.platform
== "win32":
258 setup_args
['zip_safe'] = False
260 py_25
= sys
.version_info
[0] > 2 or (sys
.version_info
[0] == 2 and sys
.version_info
[1] >= 5)
261 py_26
= sys
.version_info
[0] > 2 or (sys
.version_info
[0] == 2 and sys
.version_info
[1] >= 6)
264 # If setuptools is installed, then we'll add setuptools-specific arguments
266 import setuptools
#@UnusedImport
271 setup_args
['install_requires'] = [
275 # Python-2.6 and up includes json
277 setup_args
['install_requires'].append('simplejson')
279 # Python-2.6 and up includes a working A sqlite (py25's is broken)
281 setup_args
['install_requires'].append('pysqlite')
283 if os
.getenv('NO_INSTALL_REQS'):
284 setup_args
['install_requires'] = None