From 102195e4284e26dff6562a6e387b1a510fad8d3a Mon Sep 17 00:00:00 2001 From: Kai Schlamp Date: Wed, 20 Mar 2024 22:16:23 +0000 Subject: [PATCH] Extract version from pyproject.toml without raising when not existent --- radis/settings/base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/radis/settings/base.py b/radis/settings/base.py index 571b8a8d..1a163ef5 100644 --- a/radis/settings/base.py +++ b/radis/settings/base.py @@ -20,10 +20,14 @@ # The base directory of the project (the root of the repository) BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent -# Read pyproject.toml file -pyproject = toml.load(BASE_DIR / "pyproject.toml") - -RADIS_VERSION = pyproject["tool"]["poetry"]["version"] +# Read pyproject.toml to fetch current version +# We to do this conditionally as radis_client uses RADIS for testing as a package where +# the file is not present. +if (BASE_DIR / "pyproject.toml").exists(): + pyproject = toml.load(BASE_DIR / "pyproject.toml") + RADIS_VERSION = pyproject["tool"]["poetry"]["version"] +else: + RADIS_VERSION = "???" READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False) # type: ignore if READ_DOT_ENV_FILE: