From ed8649fee7c81a0b6cd71f11e76f93c58b25cf64 Mon Sep 17 00:00:00 2001 From: Mohammad Ahtasham ul Hassan Date: Wed, 17 Nov 2021 15:20:43 +0500 Subject: [PATCH] build: standardize version number placement --- acid/__init__.py | 2 ++ setup.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/acid/__init__.py b/acid/__init__.py index 497e3c5..c31e5fa 100644 --- a/acid/__init__.py +++ b/acid/__init__.py @@ -1 +1,3 @@ from .acid import AcidBlock, AcidParentBlock, AcidAside + +__version__ = '0.2.1' diff --git a/setup.py b/setup.py index e49d730..b9b7f6b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ """Set up for XBlock acid block.""" import os +import re from setuptools import setup @@ -31,6 +32,20 @@ def load_requirements(*requirements_paths): return list(requirements) +def get_version(file_path): + """ + Extract the version string from the file at the given relative path fragments. + """ + filename = os.path.join(os.path.dirname(__file__), file_path) + with open(filename, encoding='utf-8') as opened_file: + version_file = opened_file.read() + version_match = re.search(r"(?m)^__version__ = ['\"]([^'\"]+)['\"]", version_file) + if version_match: + return version_match.group(1) + raise RuntimeError('Unable to find version string.') + + +VERSION = get_version("acid/__init__.py") README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read() @@ -44,7 +59,7 @@ def is_requirement(line): setup( name='acid-xblock', - version='0.2.1', + version=VERSION, description='Acid XBlock Test', long_description=README, long_description_content_type='text/markdown',