From c5b2df754ee2c1d482a008d1cb5bf622c1aa5592 Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 27 Jun 2023 22:36:29 +0200 Subject: [PATCH] Save auto version number Fixed #108 --- morss/__init__.py | 2 ++ setup.py | 24 +++++++++++++++++++++++- 2 files changed, 25 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..2c171a9 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,33 @@ 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',