diff --git a/docs/tutorial/install-advanced.md b/docs/tutorial/install-advanced.md index a46cbd6e..897277c1 100644 --- a/docs/tutorial/install-advanced.md +++ b/docs/tutorial/install-advanced.md @@ -77,7 +77,22 @@ uv sync --group prod C'est parce que ces dépendances compilent certains modules à l'installation. -## Configurer Redis +## Désactiver Honcho + +Honcho est utilisé en développement pour simplifier la gestion +des services externes (redis, vite et autres futures). + +En mode production, il est nécessaire de le désactiver puisque normalement +tous ces services sont déjà configurés. + +Pour désactiver Honcho il suffit de sélectionner aucun `PROCFILE_` dans la config. + +```dotenv +PROCFILE_RUNSERVER= +PROCFILE_PYTEST= +``` + +## Configurer Redis en service externe Redis est installé comme dépendance mais pas lancé par défaut. @@ -100,6 +115,11 @@ REDIS_PORT=6379 CACHE_URL=redis://127.0.0.1:${REDIS_PORT}/0 ``` +Si on souhaite configurer redis pour communiquer via un socket : + +```dovenv +CACHE_URL=redis:///path/to/redis-server.sock +``` ## Configurer PostgreSQL diff --git a/manage.py b/manage.py index 71939ec3..444f6799 100755 --- a/manage.py +++ b/manage.py @@ -18,19 +18,16 @@ import sys from django.utils.autoreload import DJANGO_AUTORELOAD_ENV -from processes.composer import start_composer, stop_composer -from sith.environ import env +from sith.composer import start_composer, stop_composer +from sith.settings import PROCFILE_RUNSERVER if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sith.settings") from django.core.management import execute_from_command_line - if ( - os.environ.get(DJANGO_AUTORELOAD_ENV) is None - and (procfile := env.str("PROCFILE_RUNSERVER", None)) is not None - ): - start_composer(procfile) + if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and PROCFILE_RUNSERVER is not None: + start_composer(PROCFILE_RUNSERVER) execute_from_command_line(sys.argv) diff --git a/pyproject.toml b/pyproject.toml index d5d3c1f0..7be2162c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,10 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "google" +[build-system] # A build system is needed to register a pytest plugin +requires = ["hatchling"] +build-backend = "hatchling.build" + [project.entry-points.pytest11] sith = "sith.pytest" diff --git a/processes/composer.py b/sith/composer.py similarity index 100% rename from processes/composer.py rename to sith/composer.py diff --git a/sith/environ.py b/sith/environ.py deleted file mode 100644 index 0b048822..00000000 --- a/sith/environ.py +++ /dev/null @@ -1,4 +0,0 @@ -from environs import Env - -env = Env() -_ = env.read_env() diff --git a/sith/pytest.py b/sith/pytest.py index 3a99a7fc..29250e16 100644 --- a/sith/pytest.py +++ b/sith/pytest.py @@ -1,10 +1,8 @@ import pytest -from processes.composer import start_composer, stop_composer +from .composer import start_composer, stop_composer +from .settings import PROCFILE_PYTEST -from .environ import env - -# pytest-django uses the load_initial_conftest hook # it's the first hook loaded by pytest and can only # be defined in a proper pytest plugin # To use the composer before pytest-django loads @@ -15,8 +13,8 @@ from .environ import env @pytest.hookimpl(tryfirst=True) def pytest_load_initial_conftests(early_config, parser, args): """Hook that loads the composer before the pytest-django plugin""" - if (procfile := env.str("PROCFILE_PYTEST", None)) is not None: - start_composer(procfile) + if PROCFILE_PYTEST is not None: + start_composer(PROCFILE_PYTEST) def pytest_unconfigure(config): diff --git a/sith/settings.py b/sith/settings.py index b283c3e6..cc434703 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -42,13 +42,20 @@ from pathlib import Path import sentry_sdk from dateutil.relativedelta import relativedelta from django.utils.translation import gettext_lazy as _ +from environs import Env from sentry_sdk.integrations.django import DjangoIntegration -from .environ import env from .honeypot import custom_honeypot_error +env = Env() +env.read_env() + BASE_DIR = Path(__file__).parent.parent.resolve() +# Composer settings +PROCFILE_RUNSERVER = env.str("PROCFILE_RUNSERVER", None) +PROCFILE_PYTEST = env.str("PROCFILE_PYTEST", None) + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ diff --git a/uv.lock b/uv.lock index 11b00547..f96b078e 100644 --- a/uv.lock +++ b/uv.lock @@ -1513,7 +1513,7 @@ wheels = [ [[package]] name = "sith" version = "3" -source = { virtual = "." } +source = { editable = "." } dependencies = [ { name = "cryptography" }, { name = "dict2xml" },