From 3853c38bab03c7ee34d7f56c03d2d86c7eb1775d Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Tue, 1 Jun 2010 18:23:47 +0200 Subject: [PATCH] Define the version number properly inside the module, read within setup.py. --- django_tables/__init__.py | 3 +++ setup.py | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/django_tables/__init__.py b/django_tables/__init__.py index f32db84..ad600eb 100644 --- a/django_tables/__init__.py +++ b/django_tables/__init__.py @@ -1,3 +1,6 @@ +__version__ = (0, 1, 'dev') + + from memory import * from models import * from columns import * diff --git a/setup.py b/setup.py index 72ce82a..3f72502 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,27 @@ import os from distutils.core import setup + +# Figure out the version; this could be done by importing the +# module, though that requires Django to be already installed, +# which may not be the case when processing a pip requirements +# file, for example. +import re +here = os.path.dirname(os.path.abspath(__file__)) +version_re = re.compile( + r'__version__ = (\(.*?\))') +fp = open(os.path.join(here, 'django_tables', '__init__.py')) +version = None +for line in fp: + match = version_re.search(line) + if match: + version = eval(match.group(1)) + break +else: + raise Exception("Cannot find version in __init__.py") +fp.close() + + def find_packages(root): # so we don't depend on setuptools; from the Storm ORM setup.py packages = [] @@ -9,9 +30,10 @@ def find_packages(root): packages.append(directory.replace(os.sep, '.')) return packages + setup( name = 'django-tables', - version = '0.1', + version=".".join(map(str, version)), description = 'Render QuerySets as tabular data in Django.', author = 'Michael Elsdoerfer', author_email = 'michael@elsdoerfer.info', -- 2.26.2