From 5b7bb71a0c32006415a0e1e4388c44f09601d81f Mon Sep 17 00:00:00 2001 From: Mohammad Ahtasham ul Hassan Date: Mon, 8 Nov 2021 13:02:42 +0500 Subject: [PATCH] build: standardize version number placement add edxsearch to bundle, fixed quality issues, and standardized version number placement --- edxsearch/__init__.py | 2 ++ setup.py | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/edxsearch/__init__.py b/edxsearch/__init__.py index a28719c5..c9b97b4f 100644 --- a/edxsearch/__init__.py +++ b/edxsearch/__init__.py @@ -1 +1,3 @@ """ Container module for testing / demoing search """ + +__version__ = '3.1.0' diff --git a/setup.py b/setup.py index 6423de27..a992dbd2 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ #!/usr/bin/env python """ Setup to allow pip installs of edx-search module """ +import os +import re from setuptools import setup @@ -29,9 +31,26 @@ def is_requirement(line): return line and not line.startswith(('-r', '#', '-e', 'git+', '-c')) +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('edxsearch', '__init__.py') + + setup( name='edx-search', - version='3.1.0', + version=VERSION, description='Search and index routines for index access', author='edX', author_email='oscm@edx.org', @@ -52,6 +71,6 @@ def is_requirement(line): 'Framework :: Django :: 3.1', 'Framework :: Django :: 3.2', ], - packages=['search', 'search.tests'], + packages=['search', 'search.tests', 'edxsearch'], install_requires=load_requirements('requirements/base.in') )