Skip to content

Commit 977e7dc

Browse files
committed
Merge pull request #24 from vitalk/single-sourcing-package-version
Single sourcing package version
2 parents 09c3f69 + f6b3fdb commit 977e7dc

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
# built documents.
5151
#
5252
# The short X.Y version.
53-
version = '0.7.0'
53+
version = __import__('pytest_flask').__version__
5454
# The full version, including alpha/beta/rc tags.
55-
release = '0.7.0'
55+
release = __import__('pytest_flask').__version__
5656

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

pytest_flask/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
4+
__version__ = "0.7.1"

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,31 @@ def app():
101101
**suggestion**.
102102
103103
"""
104+
import io
104105
import os
105-
import codecs
106+
import re
106107
from setuptools import setup
107108
from setuptools import find_packages
108109

109110

110-
version = "0.7.0"
111-
112-
113111
def read(*parts):
114112
"""Reads the content of the file located at path created from *parts*."""
115113
try:
116-
return codecs.open(os.path.join(*parts), 'r', encoding='utf-8').read()
114+
return io.open(os.path.join(*parts), 'r', encoding='utf-8').read()
117115
except IOError:
118116
return ''
119117

120118

119+
def get_version():
120+
version_file = read('pytest_flask', '__init__.py')
121+
version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]',
122+
version_file, re.MULTILINE)
123+
if version_match:
124+
return version_match.group(1)
125+
raise RuntimeError('Unable to find version string.')
126+
127+
128+
version = get_version()
121129
requirements = read('requirements', 'main.txt').splitlines()
122130
tests_require = []
123131

0 commit comments

Comments
 (0)