From a6c8db1dd32051cfbf11035410af955ebc16ad68 Mon Sep 17 00:00:00 2001 From: Matti Lamppu Date: Tue, 29 Oct 2024 19:19:30 +0200 Subject: [PATCH] Add support for python 3.13 --- .github/workflows/test.yml | 2 +- config/settings.py | 46 +++++++++++++------------------------- docker/Dockerfile | 5 +++-- poetry.lock | 4 ++-- pyproject.toml | 4 ++-- 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 013510ed2..daa680d8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,7 +68,7 @@ jobs: id: setup-python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: "Load cached poetry installation" uses: actions/cache@v4 diff --git a/config/settings.py b/config/settings.py index 3f2493478..289a8189f 100644 --- a/config/settings.py +++ b/config/settings.py @@ -5,6 +5,7 @@ from django.utils.translation import gettext_lazy as _ from env_config import Environment, values +from env_config.decorators import classproperty from helusers.defaults import SOCIAL_AUTH_PIPELINE try: @@ -113,8 +114,7 @@ class Common(Environment): SOURCE_BRANCH_NAME: str = values.StringValue(default="") SOURCE_VERSION: str = values.StringValue(default="") - @classmethod - @property + @classproperty def APP_VERSION(cls) -> str: """Either the release tag or git short hash (or "local" if running locally)""" return cls.SOURCE_BRANCH_NAME.replace("main", "") or cls.SOURCE_VERSION[:8] or "local" @@ -214,8 +214,7 @@ def APP_VERSION(cls) -> str: APP_LOGGING_LEVEL = values.StringValue(default="WARNING") - @classmethod - @property + @classproperty def LOGGING(cls): return { "version": 1, @@ -324,16 +323,14 @@ def LOGGING(cls): "tilavarauspalvelu.utils.helauth.pipeline.migrate_user_from_tunnistamo_to_keycloak", ) - @classmethod - @property + @classproperty def OIDC_AUTH(cls): # See 'oidc_auth/settings.py' return { "OIDC_LEEWAY": cls.OIDC_LEEWAY, } - @classmethod - @property + @classproperty def OIDC_API_TOKEN_AUTH(cls): # See 'helusers/settings.py' return { @@ -412,13 +409,11 @@ def OIDC_API_TOKEN_AUTH(cls): CELERY_QUEUE_FOLDER_IN = values.StringValue(default="/broker/queue/") CELERY_PROCESSED_FOLDER = values.StringValue(default="/broker/processed/") - @classmethod - @property + @classproperty def CELERY_BROKER_URL(cls): return "filesystem://" - @classmethod - @property + @classproperty def CELERY_BROKER_TRANSPORT_OPTIONS(cls): # Use filesystem as message broker return { @@ -432,8 +427,7 @@ def CELERY_BROKER_TRANSPORT_OPTIONS(cls): REDIS_URL = values.StringValue() - @classmethod - @property + @classproperty def CACHES(cls): return { "default": { @@ -450,8 +444,7 @@ def CACHES(cls): ELASTICSEARCH_URL = values.StringValue() DISABLE_ELASTICSEARCH_INDEXES = values.BooleanValue(default=False) - @classmethod - @property + @classproperty def SEARCH_SETTINGS(cls): return { "connections": { @@ -686,8 +679,7 @@ class Local(Common, overrides_from=LocalMixin): ELASTICSEARCH_URL = values.StringValue(default="http://localhost:9200") - @classmethod - @property + @classproperty def SEARCH_SETTINGS(cls): search_settings = super().SEARCH_SETTINGS search_settings["settings"]["mappings_dir"] = str(Common.BASE_DIR / "config" / "elasticsearch") @@ -740,13 +732,11 @@ class Docker(Common, overrides_from=DockerMixin): REDIS_URL = values.StringValue(default="redis://redis:6379/0") ELASTICSEARCH_URL = values.StringValue(default="http://elastic:9200") - @classmethod - @property + @classproperty def CELERY_BROKER_URL(cls): return cls.REDIS_URL - @classmethod - @property + @classproperty def CELERY_BROKER_TRANSPORT_OPTIONS(cls): return {} @@ -868,8 +858,7 @@ class AutomatedTests(EmptyDefaults, Common, dotenv_path=None, overrides_from=Aut ELASTICSEARCH_URL = values.StringValue(default="http://localhost:9200") - @classmethod - @property + @classproperty def SEARCH_SETTINGS(cls): search_settings = super().SEARCH_SETTINGS search_settings["settings"]["mappings_dir"] = str(Common.BASE_DIR / "config" / "elasticsearch") @@ -941,8 +930,7 @@ class Platta(Common, use_environ=True): DJANGO_REDIS_CONNECTION_FACTORY = "django_redis.pool.SentinelConnectionFactory" - @classmethod - @property + @classproperty def CACHES(cls): sentinel_host, sentinel_port = cls.REDIS_SENTINEL_SERVICE.split(":") return { @@ -960,13 +948,11 @@ def CACHES(cls): # --- Celery settings -------------------------------------------------------------------------------------------- - @classmethod - @property + @classproperty def CELERY_BROKER_URL(cls): return f"sentinel://:{cls.REDIS_PASSWORD}@{cls.REDIS_SENTINEL_SERVICE}" - @classmethod - @property + @classproperty def CELERY_BROKER_TRANSPORT_OPTIONS(cls): # Use redis as message broker return { diff --git a/docker/Dockerfile b/docker/Dockerfile index 2bbc503f6..278834356 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM public.ecr.aws/docker/library/python:3.12-slim-bullseye AS base +FROM public.ecr.aws/docker/library/python:3.13-slim-bullseye AS base # Make sure we build as the root user. USER root @@ -54,11 +54,12 @@ ARG DEPS=main,admin,celery # Install build dependencies # - build-essential: for building uWSGI # - curl: for installing poetry -# - libpcre3 & libpcre3-dev: for uWSGI internal routing support +# - libpcre2-dev & libpcre3 & libpcre3-dev: for uWSGI internal routing support # - libpq-dev: for building psycopg2 RUN apt-get install -y --no-install-recommends \ build-essential \ curl \ + libpcre2-dev \ libpcre3 \ libpcre3-dev \ libpq-dev \ diff --git a/poetry.lock b/poetry.lock index 7ef11851d..9880d7b3d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3453,5 +3453,5 @@ test = ["coverage (>=5.3)", "tomli (>=2.0.1)", "tox"] [metadata] lock-version = "2.0" -python-versions = ">=3.12,<3.13" -content-hash = "84e8fbb65ce8fab5a414ec6427a7b6ba7408fe98f272de6d2ad726b2d35c4a32" +python-versions = ">=3.13,<3.14" +content-hash = "7ec27af434c013ff9f9f39af57711769f2f35d208b8b307a6ab0f58c2a327c42" diff --git a/pyproject.toml b/pyproject.toml index 834a02061..619bef9ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = ">=3.12,<3.13" +python = ">=3.13,<3.14" Django = "5.1.3" django-auditlog = "3.0.0" django-cors-headers = "4.6.0" @@ -87,7 +87,7 @@ tilavarauspalvelu = "tests.plugins" fix = true unsafe-fixes = true line-length = 120 -target-version = "py312" +target-version = "py313" extend-exclude = [ "build", "local_settings.py",