Skip to content

Commit

Permalink
Also get buildslave's version from GIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
thmo committed Oct 1, 2010
1 parent b3d247e commit 51c2661
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
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 51c2661

Please sign in to comment.