Skip to content

Commit

Permalink
Add support for python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
matti-lamppu committed Nov 19, 2024
1 parent e591590 commit a6c8db1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 16 additions & 30 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -432,8 +427,7 @@ def CELERY_BROKER_TRANSPORT_OPTIONS(cls):

REDIS_URL = values.StringValue()

@classmethod
@property
@classproperty
def CACHES(cls):
return {
"default": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit a6c8db1

Please sign in to comment.