-VERSION = $(shell cat VERSION)
-TAGVER = $(shell cat VERSION | sed -e "s/\([0-9\.]*\).*/\1/")
+VERSION = $(shell sed -ne 's/__version__\s*=\s*[\x22\x27]\([^\x22\x27]\+\)[\x22\x27].*/\1/p ' gitbuildsys/__init__.py)
+TAGVER = $(shell echo $(VERSION) | sed -e "s/\([0-9\.]*\).*/\1/")
PKGNAME = gbs
ifeq ($(VERSION), $(TAGVER))
import os, sys
import glob
+import re
+
from distutils.core import setup
try:
import setuptools
pass
MOD_NAME = 'gitbuildsys'
-
-version_path = 'VERSION'
+version_path = os.path.join(MOD_NAME, "__init__.py")
if not os.path.isfile(version_path):
- print 'No VERSION file in topdir, abort'
+ print 'No %s version file found' % version_path
sys.exit(1)
-try:
- # first line should be the version number
- version = open(version_path).readline().strip()
- if not version:
- print 'VERSION file is invalid, abort'
- sys.exit(1)
-
- ver_file = open('%s/__version__.py' % MOD_NAME, 'w')
- ver_file.write("VERSION = \"%s\"\n" % version)
- ver_file.close()
-except IOError:
- print 'WARNING: Cannot write version number file'
+content = open(version_path).read()
+match = re.search(r'^__version__\s*=\s*[\x22\x27]([^\x22\x27]+)[\x22\x27]',
+ content, re.M)
+if match:
+ version = match.group(1)
+else:
+ print 'Unable to find version in %s' % version_path
+ sys.exit(1)
# "--install-layout=deb" is required for pyver>2.5 in Debian likes
if sys.version_info[:2] > (2, 5):
import sys
import re
-from gitbuildsys.__version__ import VERSION
+from gitbuildsys import __version__
from gitbuildsys import msger, cmdln, errors
def handle_repository(option, opt_str, value, parser):
"""
name = 'gbs'
- version = VERSION
+ version = __version__
def get_optparser(self):
optparser = cmdln.CmdlnOptionParser(self, version=self.version)