Skip to content

Commit

Permalink
updates PDM packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jul 11, 2024
1 parent 82d9a8c commit 30c0ffb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ jobs:
deployable:
if:
contains(fromJSON('["refs/heads/develop", "refs/heads/staging", "refs/heads/master", "refs/heads/release"]'), github.ref)
|| startsWith(github.ref, 'refs/heads/release')
|| contains(github.event.head_commit.message, 'ci:release')
|| contains(github.event.head_commit.message, 'ci:all')
|| github.event_name == 'create'

name: "Build deployable Docker"
needs: [ test ]
Expand Down
46 changes: 6 additions & 40 deletions docker/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export DJANGO_SETTINGS_MODULE="${DJANGO_SETTINGS_MODULE:-"hope_dedup_engine.conf
mkdir -p "${MEDIA_ROOT}" "${STATIC_ROOT}" || echo "Cannot create dirs ${MEDIA_ROOT} ${STATIC_ROOT}"

case "$1" in
worker)
exec celery -A hope_dedup_engine.config.celery worker -E --loglevel=ERROR --concurrency=4
;;
beat)
exec celery -A hope_dedup_engine.config.celery beat -E --loglevel=ERROR ---scheduler django_celery_beat.schedulers:DatabaseScheduler
;;
run)
django-admin check --deploy
django-admin upgrade
Expand All @@ -17,43 +23,3 @@ case "$1" in
esac

exec "$@"

#
#case "$1" in
# run)
# if [ "$INIT_RUN_CHECK" = "1" ];then
# echo "Running Django checks..."
# django-admin check --deploy
# fi
# OPTS="--no-check -v 1"
# if [ "$INIT_RUN_UPGRADE" = "1" ];then
# if [ "$INIT_RUN_COLLECTSTATIC" != "1" ];then
# OPTS="$OPTS --no-static"
# fi
# if [ "$INIT_RUN_MIGRATATIONS" != "1" ];then
# OPTS="$OPTS --no-migrate"
# fi
# echo "Running 'upgrade $OPTS'"
# django-admin upgrade $OPTS
# fi
# set -- tini -- "$@"
# echo "Starting uwsgi..."
# exec uwsgi --ini /conf/uwsgi.ini
# ;;
# worker)
# exec celery -A hope_dedup_engine.celery worker -E --loglevel=ERROR --concurrency=4
# ;;
# beat)
# exec celery -A hope_dedup_engine.celery beat -E --loglevel=ERROR ---scheduler django_celery_beat.schedulers:DatabaseScheduler
# ;;
# dev)
# until pg_isready -h db -p 5432;
# do echo "waiting for database"; sleep 2; done;
# django-admin collectstatic --no-input
# django-admin migrate
# django-admin runserver 0.0.0.0:8000
# ;;
# *)
# exec "$@"
# ;;
#esac
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ authors = [
{name = "Domenico DiNicola", email = "[email protected]"},
]
requires-python = ">=3.12"

dependencies = [
"Django",
"celery[redis]",
Expand Down Expand Up @@ -43,9 +44,17 @@ dependencies = [
"requests>=2.32.3",
]


[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm.build]
includes = []

[tool.pdm]
distribution = true

[tool.pdm.dev-dependencies]
dev = [
"black",
Expand Down
26 changes: 26 additions & 0 deletions src/hope_dedup_engine/apps/security/backends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import TYPE_CHECKING, Any, Optional

from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend

if TYPE_CHECKING:
from django.contrib.auth.models import AbstractBaseUser
from django.http import HttpRequest


class AnyUserAuthBackend(ModelBackend):
def authenticate(
self,
request: "Optional[HttpRequest]",
username: str | None = None,
password: str | None = None,
**kwargs: Any,
) -> "AbstractBaseUser | None":
if settings.DEBUG:
user, __ = get_user_model().objects.update_or_create(
username=username,
defaults=dict(is_staff=True, is_active=True, is_superuser=True),
)
return user
return None

0 comments on commit 30c0ffb

Please sign in to comment.