From e0e628ec54b8a4d7f41f86f9f535d791a437b13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 9 Aug 2012 01:30:19 +0200 Subject: Better version computing code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Barrois --- setup.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index ace4473..9bff8d1 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,26 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import os +import re import sys from distutils.core import setup from distutils import cmd -# Remember to change in factory/__init__.py as well! -VERSION = '1.1.5' +root = os.path.abspath(os.path.dirname(__file__)) + +def get_version(*module_dir_components): + version_re = re.compile(r"^__version__ = ['\"](.*)['\"]$") + module_root = os.path.join(root, *module_dir_components) + module_init = os.path.join(module_root, '__init__.py') + with open(module_init, 'r') as f: + for line in f: + match = version_re.match(line[:-1]) + if match: + return match.groups()[0] + return '0.1.0' + +VERSION = get_version('factory') class test(cmd.Command): -- cgit v1.2.3