From 9b83cec258877687d1994770ad6369490dfeca14 Mon Sep 17 00:00:00 2001 From: Sylvain Boissel Date: Tue, 21 Jan 2025 18:19:54 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d=E2=80=98une=20variable=20d=E2=80=99en?= =?UTF-8?q?vironnement=20USE=5FPOETRY=20(#254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add optional USE_POETRY env variable * Update CI --- .env.example | 2 ++ .env.test | 1 + Makefile | 48 +++++++++++++++++++++++++++++------------------- README.md | 3 ++- pyproject.toml | 2 +- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.env.example b/.env.example index 77940f9a..41110c15 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,8 @@ MEDIA_ROOT=medias # USE_DOCKER: Set 1 to use Docker USE_DOCKER=0 +# Set 1 to use Poetry +USE_POETRY=0 DATABASE_NAME=djdb DATABASE_USER=dju diff --git a/.env.test b/.env.test index f7a1eac9..c8288f2f 100644 --- a/.env.test +++ b/.env.test @@ -6,3 +6,4 @@ DATABASE_HOST=127.0.0.1 DATABASE_PORT=5432 DEBUG=False DATABASE_URL=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} +USE_POETRY=1 diff --git a/Makefile b/Makefile index a3ff343f..342a3df8 100644 --- a/Makefile +++ b/Makefile @@ -10,80 +10,90 @@ else EXEC_CMD := endif +ifeq ($(USE_POETRY),1) + POETRY_CMD := poetry run +else + POETRY_CMD := +endif + .PHONY: web-prompt web-prompt: $(EXEC_CMD) bash .PHONY: collectstatic collectstatic: - $(EXEC_CMD) poetry run python manage.py collectstatic --noinput --ignore=*.sass + $(EXEC_CMD) $(POETRY_CMD) python manage.py collectstatic --noinput --ignore=*.sass .PHONY: messages messages: - $(EXEC_CMD) poetry run django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles + $(EXEC_CMD) $(POETRY_CMD) django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles .PHONY: sass sass: - $(EXEC_CMD) poetry run python manage.py compilescss + $(EXEC_CMD) $(POETRY_CMD) python manage.py compilescss make collectstatic .PHONY: quality quality: $(EXEC_CMD) ruff check . - $(EXEC_CMD) poetry run black --check --exclude=venv . + $(EXEC_CMD) $(POETRY_CMD) black --check --exclude=venv . .PHONY: fix fix: $(EXEC_CMD) ruff check . --fix - $(EXEC_CMD) poetry run black --exclude=venv . + $(EXEC_CMD) $(POETRY_CMD) black --exclude=venv . .PHONY: index index: - $(EXEC_CMD) poetry run python manage.py update_index + $(EXEC_CMD) $(POETRY_CMD) python manage.py update_index .PHONY: init init: $(EXEC_CMD) poetry install --no-root --without dev - $(EXEC_CMD) poetry run python manage.py migrate + $(EXEC_CMD) $(POETRY_CMD) python manage.py migrate make collectstatic - $(EXEC_CMD) poetry run python manage.py set_config - $(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms - $(EXEC_CMD) poetry run python manage.py create_starter_pages - $(EXEC_CMD) poetry run python manage.py import_page_templates + $(EXEC_CMD) $(POETRY_CMD) python manage.py set_config + $(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms + $(EXEC_CMD) $(POETRY_CMD) python manage.py create_starter_pages + $(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates make index .PHONY: init-dev init-dev: make init $(EXEC_CMD) poetry install --no-root - $(EXEC_CMD) poetry run pre-commit install + $(EXEC_CMD) $(POETRY_CMD) pre-commit install .PHONY: update update: $(EXEC_CMD) poetry install --no-root --without dev - $(EXEC_CMD) poetry run python manage.py migrate + $(EXEC_CMD) $(POETRY_CMD) python manage.py migrate make collectstatic - $(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms - $(EXEC_CMD) poetry run python manage.py import_page_templates + $(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms + $(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates make index .PHONY: demo demo: make init - $(EXEC_CMD) poetry run python manage.py create_demo_pages + $(EXEC_CMD) $(POETRY_CMD) python manage.py create_demo_pages .PHONY: runserver runserver: - $(EXEC_CMD) poetry run python manage.py runserver $(HOST_URL):$(HOST_PORT) + $(EXEC_CMD) $(POETRY_CMD) python manage.py runserver $(HOST_URL):$(HOST_PORT) + +.PHONY: shell +shell: + $(EXEC_CMD) $(POETRY_CMD) python manage.py shell_plus .PHONY: test test: - $(EXEC_CMD) poetry run python manage.py test --buffer --parallel + $(EXEC_CMD) $(POETRY_CMD) python manage.py test --buffer --parallel .PHONY: test-unit test-unit: - $(EXEC_CMD) poetry run python manage.py test --settings config.settings_test + $(EXEC_CMD) $(POETRY_CMD) python manage.py test --settings config.settings_test diff --git a/README.md b/README.md index dae4af92..24fd6c54 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ python -c "from django.core.management.utils import get_random_secret_key; print ### En local #### Installer poetry s’il ne l’est pas -Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation) +- Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation) +- mettre la variable d’environnement `USE_POETRY` à `1` dans le fichier `.env` #### Installer le projet diff --git a/pyproject.toml b/pyproject.toml index 9f20997b..fedf1086 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "sites-faciles" requires-python = "<4.0,>=3.10" -version = "1.11.2" +version = "1.11.3" description = "Gestionnaire de contenu permettant de créer et gérer un site internet basé sur le Système de design de l’État, accessible et responsive" authors = [ {name = "Sébastien Reuiller", email = "sebastien.reuiller@beta.gouv.fr"},