From aab85275c6e2c2fc009f12c49277c8e53e1a6eb2 Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 27 Jun 2023 22:30:25 +0200 Subject: [PATCH] Save auto version number Fixes #108 --- morss/__init__.py | 2 ++ setup.py | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/morss/__init__.py b/morss/__init__.py index de0ba4d..2fa36d0 100644 --- a/morss/__init__.py +++ b/morss/__init__.py @@ -19,5 +19,7 @@ # pylint: disable=unused-import,unused-variable +__version__ = "" + from .morss import * from .wsgi import application diff --git a/setup.py b/setup.py index a045ea7..c248b4e 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,32 @@ from glob import glob from setuptools import setup +def get_version(): + with open('morss/__init__.py', 'r+') as file: + lines = file.readlines() + + # look for hard coded version number + for i in range(len(lines)): + if lines[i].startswith('__version__'): + version = lines[i].split('"')[1] + break + + # create (& save) one if none found + if version == '': + version = datetime.now().strftime('%Y%m%d.%H%M') + lines[i] = '__version__ = "' + version + '"\n' + + file.seek(0) + file.writelines(lines) + + # return version number + return version + package_name = 'morss' setup( name = package_name, - version = datetime.now().strftime('%Y%m%d.%H%M'), + version = get_version(), description = 'Get full-text RSS feeds', long_description = open('README.md').read(), long_description_content_type = 'text/markdown',