From 8d3382ffda90720df9aa36fc50dbce5b3c3739ad Mon Sep 17 00:00:00 2001 From: Jyrno Ader Date: Wed, 27 Jul 2022 16:45:54 +0300 Subject: [PATCH 1/3] Support multiple envs with env caching Previously when `poetry env list` returned multiple environments then the dev django entrypoint file raised an error as the ENV_FOLDER setting did not match the available env string directly. Improved the check there to handle the case correctly and not error when the ENV_FOLDER value exists in the returned list of environments. Also: - Update production poetry install command --- {{cookiecutter.repo_name}}/Dockerfile-django.production | 3 +-- {{cookiecutter.repo_name}}/Dockerfile-django.production.debian | 3 +-- {{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.repo_name}}/Dockerfile-django.production b/{{cookiecutter.repo_name}}/Dockerfile-django.production index 2671347d..92ed407b 100644 --- a/{{cookiecutter.repo_name}}/Dockerfile-django.production +++ b/{{cookiecutter.repo_name}}/Dockerfile-django.production @@ -29,8 +29,7 @@ ENV POETRY_NO_INTERACTION 1 ENV POETRY_VIRTUALENVS_CREATE 0 ENV PATH="$POETRY_HOME/bin:$PATH" -RUN wget https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py && \ - python3 get-poetry.py +RUN wget -O - -o /dev/null https://install.python-poetry.org | python3 - COPY pyproject.toml / COPY poetry.lock / diff --git a/{{cookiecutter.repo_name}}/Dockerfile-django.production.debian b/{{cookiecutter.repo_name}}/Dockerfile-django.production.debian index c5d0c381..0e30fd9b 100644 --- a/{{cookiecutter.repo_name}}/Dockerfile-django.production.debian +++ b/{{cookiecutter.repo_name}}/Dockerfile-django.production.debian @@ -28,8 +28,7 @@ ENV POETRY_NO_INTERACTION 1 ENV POETRY_VIRTUALENVS_CREATE 0 ENV PATH="$POETRY_HOME/bin:$PATH" -RUN wget https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py && \ - python3 get-poetry.py +RUN wget -O - -o /dev/null https://install.python-poetry.org | python3 - COPY pyproject.toml / COPY poetry.lock / diff --git a/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh b/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh index 30ebe34d..82b112c0 100755 --- a/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh +++ b/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh @@ -59,7 +59,8 @@ fi if [[ "${DPT_VENV_CACHING}" -eq "1" ]]; then reported_path=$(poetry env list | cut -f 1 -d ' ') - if [[ "${reported_path}" != "${ENV_FOLDER}" ]]; then + # Bail out if ENV_FOLDER does not matc reported_path or if it does not exists in the poetry env list (when multiple are available). + if [[ "${reported_path}" != "${ENV_FOLDER}" ]] && [[ $reported_path != *"${ENV_FOLDER}"* ]]; then echo "The env folder path does not match ENV_FOLDER setting. Please update ENV_FOLDER" echo " in Dockerfile-django." echo "" From 893abda76cbf832232def54f9f78fd58ec9fab85 Mon Sep 17 00:00:00 2001 From: Tonis Fraser Roubel Piip Date: Wed, 27 Jul 2022 14:55:36 +0000 Subject: [PATCH 2/3] Typo --- {{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh b/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh index 82b112c0..cfe734da 100755 --- a/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh +++ b/{{cookiecutter.repo_name}}/scripts/django-dev-entrypoint.sh @@ -59,7 +59,7 @@ fi if [[ "${DPT_VENV_CACHING}" -eq "1" ]]; then reported_path=$(poetry env list | cut -f 1 -d ' ') - # Bail out if ENV_FOLDER does not matc reported_path or if it does not exists in the poetry env list (when multiple are available). + # Bail out if ENV_FOLDER does not match reported_path or if it does not exists in the poetry env list (when multiple are available). if [[ "${reported_path}" != "${ENV_FOLDER}" ]] && [[ $reported_path != *"${ENV_FOLDER}"* ]]; then echo "The env folder path does not match ENV_FOLDER setting. Please update ENV_FOLDER" echo " in Dockerfile-django." From da046a31a35ad95d177c67cc36905d49a4e98433 Mon Sep 17 00:00:00 2001 From: Jyrno Ader Date: Wed, 27 Jul 2022 18:19:15 +0300 Subject: [PATCH 3/3] MYPY: Exclude tests and local.py files --- {{cookiecutter.repo_name}}/pyproject.toml | 1 + .../{{cookiecutter.repo_name}}/.prospector.yaml | 1 + .../{{cookiecutter.repo_name}}/mypy.ini | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index fb0861c1..055a57b0 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -104,6 +104,7 @@ exclude = ''' | build | dist | docs + | cover )/ | local.py | local_test.py diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/.prospector.yaml b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/.prospector.yaml index c9c36ca9..f7ab0910 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/.prospector.yaml +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/.prospector.yaml @@ -9,6 +9,7 @@ ignore-paths: ignore-patterns: - migrations/ - htmlcov/ + - cover/ pycodestyle: enable: diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/mypy.ini b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/mypy.ini index 3cb0c21e..41ad9e77 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/mypy.ini +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/mypy.ini @@ -13,6 +13,13 @@ warn_redundant_casts = True warn_unused_configs = True warn_unreachable = True warn_no_return = True +exclude = (?x)( + local\.py$ + | local_test\.py$ + | test_(.+) + | tests\.py + | tests + ) plugins = mypy_django_plugin.main,