From 4668c166f90050c4e3fe12605cb8cae9a2af0028 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 4 Sep 2023 22:50:35 +0100 Subject: [PATCH] Get version dynamically from pyproject.toml file --- metricity/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/metricity/__init__.py b/metricity/__init__.py index e5d4e4d..8430cfa 100644 --- a/metricity/__init__.py +++ b/metricity/__init__.py @@ -3,9 +3,11 @@ import asyncio import logging import os +from pathlib import Path from typing import TYPE_CHECKING import coloredlogs +import toml from pydis_core.utils import apply_monkey_patches from metricity.config import PythonConfig @@ -13,7 +15,11 @@ if TYPE_CHECKING: from metricity.bot import Bot -__version__ = "2.0.1" +# Read the version from the pyproject.toml file. +with Path.open("pyproject.toml") as f: + package_vers = toml.load(f)["tool"]["poetry"]["version"] + +__version__ = package_vers # Set root log level logging.basicConfig(level=PythonConfig.log_level)