Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/thmo/buildbot
Browse files Browse the repository at this point in the history
* 'master' of git://github.com/thmo/buildbot:
  Also get buildslave's version from GIT.
  Cosmetics: Shorten line.
  Record VERSION in outfiles.
  • Loading branch information
Dustin J. Mitchell committed Oct 1, 2010
2 parents 8d02715 + 51c2661 commit bfea855
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
7 changes: 5 additions & 2 deletions master/setup.py
Expand Up @@ -146,14 +146,17 @@ def finalize_options(self):
def run(self):
install_data.run(self)
# ensure there's a buildbot/VERSION file
open(os.path.join(self.install_dir, 'buildbot', 'VERSION'), 'w').write(version)
fn = os.path.join(self.install_dir, 'buildbot', 'VERSION')
open(fn, 'w').write(version)
self.outfiles.append(fn)

class our_sdist(sdist):

def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
# ensure there's a buildbot/VERSION file
open(os.path.join(base_dir, 'buildbot', 'VERSION'), 'w').write(version)
fn = os.path.join(base_dir, 'buildbot', 'VERSION')
open(fn, 'w').write(version)


long_description="""
Expand Down
28 changes: 28 additions & 0 deletions slave/buildslave/__init__.py
@@ -1 +1,29 @@
# strategy:
#
# if there is a VERSION file, use its contents. otherwise, call git to
# get a version string. if that also fails, use 'latest'.
#
import os

version = "latest"

try:
fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')
version = open(fn).read().strip()

except IOError:
from subprocess import Popen, PIPE
import re

VERSION_MATCH = re.compile(r'\d+\.\d+\.\d+(\w|-)*')

try:
p = Popen(['git', 'describe', '--tags', '--always', '--dirty'], stdout=PIPE)
out = p.communicate()[0]

if (not p.returncode) and out:
v = VERSION_MATCH.search(out)
if v:
version = v.group()
except OSError:
pass
28 changes: 27 additions & 1 deletion slave/setup.py
Expand Up @@ -13,6 +13,8 @@
import sys
import os
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.command.sdist import sdist

from buildslave import version

Expand All @@ -22,6 +24,23 @@
if 'sdist' in sys.argv or sys.platform == 'win32':
scripts.append("contrib/windows/buildslave.bat")

class our_install_data(install_data):

def run(self):
install_data.run(self)
# ensure there's a buildslave/VERSION file
fn = os.path.join(self.install_dir, 'buildslave', 'VERSION')
open(fn, 'w').write(version)
self.outfiles.append(fn)

class our_sdist(sdist):

def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
# ensure there's a buildslave/VERSION file
fn = os.path.join(base_dir, 'buildslave', 'VERSION')
open(fn, 'w').write(version)

setup_args = {
'name': "buildbot-slave",
'version': version,
Expand Down Expand Up @@ -51,7 +70,14 @@
"buildslave.test.util",
"buildslave.test.unit",
],
'scripts': scripts
'scripts': scripts,
# mention data_files, even if empty, so install_data is called and
# VERSION gets copied
'data_files': [("buildslave", [])],
'cmdclass': {
'install_data': our_install_data,
'sdist': our_sdist
}
}

# set zip_safe to false to force Windows installs to always unpack eggs
Expand Down

0 comments on commit bfea855

Please sign in to comment.