Skip to content

Commit f8ecfea

Browse files
committed
Move version string into a python script
1 parent ef5eefc commit f8ecfea

5 files changed

Lines changed: 9 additions & 19 deletions

File tree

docs/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@
6060
# |version| and |release|, also used in various other places throughout the
6161
# built documents.
6262
#
63-
# The short X.Y version.
64-
from tcod import __version__
65-
version = '.'.join(__version__)
6663
# The full version, including alpha/beta/rc tags.
67-
with open('../tcod/version.txt', 'r') as f:
68-
release = f.read()
64+
from tcod import __version__ as release
65+
# The short X.Y version.
66+
import re
67+
version = re.match(r'([0-9]+\.[0-9]+).*?', release).group()
6968

7069
# The language for content autogenerated by Sphinx. Refer to documentation
7170
# for a list of supported languages.

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
from setuptools import setup, Command
1010

11-
with open('tcod/version.txt', 'r') as f:
12-
version = f.read()
11+
exec(open('tcod/version.py').read()) # get __version__
1312

1413
def get_package_data():
1514
'''get data files which will be included in the main tcod/ directory'''
1615
BITSIZE, LINKAGE = platform.architecture()
17-
files = ['version.txt',
16+
files = [
1817
'lib/LIBTCOD-CREDITS.txt',
1918
'lib/LIBTCOD-LICENSE.txt',
2019
'lib/README-SDL.txt']
@@ -32,7 +31,7 @@ def get_package_data():
3231

3332
setup(
3433
name='libtcod-cffi',
35-
version=version,
34+
version=__version__,
3635
author='Kyle Stewart',
3736
author_email='4B796C65+tcod@gmail.com',
3837
description='A Python cffi port of libtcod.',

tcod/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@
1717
"""
1818
from __future__ import absolute_import as _
1919

20-
import os as _os
21-
22-
import re as _re
23-
2420
from tcod.libtcodpy import *
2521
from tcod.tcod import *
2622
from tcod import path
27-
28-
with open(_os.path.join(__path__[0], 'version.txt'), 'r') as _f:
29-
# exclude the git commit number (PEP 396)
30-
__version__ = _re.match(r'([0-9]+)\.([0-9]+).*?', _f.read()).groups()
31-
assert __version__, 'version.txt parse error'
23+
from tcod.version import __version__

tcod/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '2.0a5'

tcod/version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)