Skip to content

Commit 6e983db

Browse files
author
4b796c65
committed
Fancy version handling
1 parent d542894 commit 6e983db

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

setup.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
#!/usr/bin/env python
22

3+
import subprocess
4+
35
try:
46
# use setuptools or distribute if available
57
from setuptools import setup
68
except ImportError:
79
from distutils.core import setup
810

11+
base_version = '1.1.6' # base version
12+
def get_version():
13+
"""Probably a much more elegant way to do this.
14+
15+
Update tdl/VERSION.txt with the current svn version, then return the result"""
16+
try:
17+
revision = subprocess.check_output('svnversion', universal_newlines=True)[:-1]
18+
except:
19+
revision = None
20+
21+
if revision:
22+
if ':' in revision:
23+
revision = revision.split(':')[-1]
24+
if 'M' in revision:
25+
revision = revision[:-1]
26+
file = open('tdl/VERSION.txt', 'w')
27+
file.write(base_version + 'r' + revision)
28+
file.close()
29+
print('revision %s' % revision)
30+
31+
file = open('tdl/VERSION.txt', 'r')
32+
version = file.read()
33+
file.close()
34+
return version
35+
936
setup(name='tdl',
10-
version='1.1.6',
37+
version=get_version(),
1138
author='Kyle Stewart',
1239
author_email='4B796C65+pythonTDL@gmail.com',
1340
description='Pythonic port of rogue-like library libtcod.',

tdl/VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.6r79

tdl/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,3 +1331,7 @@ def forceResolution(width, height):
13311331

13321332
__license__ = "New BSD License"
13331333
__email__ = "4b796c65+pythonTDL@gmail.com"
1334+
1335+
file = open(os.path.join(os.path.dirname(__file__), 'VERSION.txt'), 'r')
1336+
__version__ = file.read()
1337+
file.close()

0 commit comments

Comments
 (0)