diff --git a/edxval/__init__.py b/edxval/__init__.py index 909de984..462c90dd 100644 --- a/edxval/__init__.py +++ b/edxval/__init__.py @@ -1,3 +1,5 @@ """ init """ + +__version__ = '2.1.1' diff --git a/setup.py b/setup.py index db39c864..ad9d99d0 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import os +import re import sys from setuptools import setup @@ -47,7 +48,21 @@ def load_requirements(*requirements_paths): return list(requirements) -VERSION = '2.1.1' +def get_version(*file_paths): + """ + Extract the version string from the file at the given relative path fragments. + """ + filename = os.path.join(os.path.dirname(__file__), *file_paths) + with open(filename, encoding='utf-8') as opened_file: + version_file = opened_file.read() + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError('Unable to find version string.') + + +VERSION = get_version("edxval", "__init__.py") if sys.argv[-1] == 'tag': print("Tagging the version on github:")