diff --git a/.github/workflows/impress.yml b/.github/workflows/impress.yml index 0c5b38cf..896f07ef 100644 --- a/.github/workflows/impress.yml +++ b/.github/workflows/impress.yml @@ -107,7 +107,9 @@ jobs: - name: Install Python uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: "3.12.6" + - name: Upgrade pip and setuptools + run: pip install --upgrade pip setuptools - name: Install development dependencies run: pip install --user .[dev] - name: Check code formatting with ruff @@ -199,7 +201,7 @@ jobs: - name: Install Python uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: "3.12.6" - name: Install development dependencies run: pip install --user .[dev] diff --git a/src/backend/impress/settings.py b/src/backend/impress/settings.py index cbdde169..860ef32a 100755 --- a/src/backend/impress/settings.py +++ b/src/backend/impress/settings.py @@ -10,8 +10,8 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ -import json import os +import tomllib from django.utils.translation import gettext_lazy as _ @@ -27,19 +27,12 @@ DATA_DIR = os.path.join("/", "data") def get_release(): """ Get the current release of the application - - By release, we mean the release from the version.json file à la Mozilla [1] - (if any). If this file has not been found, it defaults to "NA". - - [1] - https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md """ - # Try to get the current release from the version.json file generated by the - # CI during the Docker image build try: - with open(os.path.join(BASE_DIR, "version.json"), encoding="utf8") as version: - return json.load(version)["version"] - except FileNotFoundError: + with open(os.path.join(BASE_DIR, "pyproject.toml"), "rb") as f: + pyproject_data = tomllib.load(f) + return pyproject_data["project"]["version"] + except (FileNotFoundError, KeyError): return "NA" # Default: not available diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index 00bc5b10..1e920839 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -127,6 +127,7 @@ select = [ [tool.ruff.lint.isort] section-order = ["future","standard-library","django","third-party","impress","first-party","local-folder"] sections = { impress=["core"], django=["django"] } +extra-standard-library = ["tomllib"] [tool.ruff.lint.per-file-ignores] "**/tests/*" = ["S", "SLF"]