diff --git a/.bzrignore b/.bzrignore index d61f71f..9620ab1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,3 +1,4 @@ build dist oxutils.egg-info +ox/__version.py diff --git a/ox/__init__.py b/ox/__init__.py index 18a2a91..ce09413 100644 --- a/ox/__init__.py +++ b/ox/__init__.py @@ -1,7 +1,11 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 # GPL 2011 -__version__ = '2.1.1' +try: + from . import __version + __version__ = __version.VERSION +except: + __version__ = '2.1.x' from . import cache from . import js diff --git a/setup.py b/setup.py index 6055fba..45460eb 100644 --- a/setup.py +++ b/setup.py @@ -6,29 +6,32 @@ try: except: from distutils.core import setup -def get_bzr_version(): +def get_version(): import os import re info = os.path.join(os.path.dirname(__file__), '.bzr/branch/last-revision') - changelog = os.path.join(os.path.dirname(__file__), 'debian/changelog') + __version = os.path.join(os.path.dirname(__file__), 'ox/__version.py') if os.path.exists(info): f = open(info) rev = int(f.read().split()[0]) f.close() if rev: - return u'%s' % rev - elif os.path.exists(changelog): - f = open(changelog) - head = f.read().strip().split('\n')[0] - f.close() - rev = re.compile('\d+\.\d+\.(\d+)').findall(head) - if rev: - return u"%s" % rev[0] - return u'unknown' + version = u"2.1.%s"%rev + with open(__version, 'w') as fd: + fd.write('VERSION="%s"'%version) + return version + elif os.path.exists(__version): + with open(__version) as fd: + data = fd.read().strip().split('\n')[0] + version = re.compile('VERSION="(.*)"').findal(data) + if version: + version = version[0] + return version + return u'2.1.x' setup( name="ox", - version="2.1.%s" % get_bzr_version() , + version=get_version() , description="python-ox - the web in a dict", author="0x2620", author_email="0x2620@0x2620.org",