Skip to content

Commit

Permalink
Extract version from pyproject.toml without raising when not existent
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Mar 20, 2024
1 parent 2f65467 commit 102195e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions radis/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 102195e

Please sign in to comment.