From 2b7813f715083b6e667d1e18b314712ab2cb10ef Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 7 Dec 2023 19:43:30 +0100 Subject: [PATCH] Make "gptbot -v" actually output the correct version --- src/gptbot/__main__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gptbot/__main__.py b/src/gptbot/__main__.py index f50eb3b..ef195c4 100644 --- a/src/gptbot/__main__.py +++ b/src/gptbot/__main__.py @@ -5,11 +5,18 @@ from configparser import ConfigParser import signal import asyncio - +import pkg_resources def sigterm_handler(_signo, _stack_frame): exit() +def get_version(): + try: + package_version = pkg_resources.get_distribution("matrix_gptbot").version + except pkg_resources.DistributionNotFound: + return None + return package_version + if __name__ == "__main__": # Parse command line arguments @@ -25,7 +32,7 @@ if __name__ == "__main__": "-v", help="Print version and exit", action="version", - version="GPTBot v0.1.1", + version=f"GPTBot {get_version() or '- version unknown'}", ) args = parser.parse_args()