Skip to content

Commit 3853c38

Browse files
committed
Define the version number properly inside the module, read within setup.py.
1 parent 48ea11f commit 3853c38

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

django_tables/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__version__ = (0, 1, 'dev')
2+
3+
14
from memory import *
25
from models import *
36
from columns import *

setup.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
import os
22
from distutils.core import setup
33

4+
5+
# Figure out the version; this could be done by importing the
6+
# module, though that requires Django to be already installed,
7+
# which may not be the case when processing a pip requirements
8+
# file, for example.
9+
import re
10+
here = os.path.dirname(os.path.abspath(__file__))
11+
version_re = re.compile(
12+
r'__version__ = (\(.*?\))')
13+
fp = open(os.path.join(here, 'django_tables', '__init__.py'))
14+
version = None
15+
for line in fp:
16+
match = version_re.search(line)
17+
if match:
18+
version = eval(match.group(1))
19+
break
20+
else:
21+
raise Exception("Cannot find version in __init__.py")
22+
fp.close()
23+
24+
425
def find_packages(root):
526
# so we don't depend on setuptools; from the Storm ORM setup.py
627
packages = []
@@ -9,9 +30,10 @@ def find_packages(root):
930
packages.append(directory.replace(os.sep, '.'))
1031
return packages
1132

33+
1234
setup(
1335
name = 'django-tables',
14-
version = '0.1',
36+
version=".".join(map(str, version)),
1537
description = 'Render QuerySets as tabular data in Django.',
1638
author = 'Michael Elsdoerfer',
1739
author_email = 'michael@elsdoerfer.info',

0 commit comments

Comments
 (0)