From 219dbe922cc8280ae5edef06fb037e4a60c0a1a9 Mon Sep 17 00:00:00 2001 From: babymonkey1111 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 2671347..92ed407 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 c5d0c38..0e30fd9 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 30ebe34..82b112c 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 4fb3038aa1b2109474e6c8fa786c052af9eae823 Mon Sep 17 00:00:00 2001 From: babymonkey1111 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 82b112c..cfe734d 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 19fe87a633406a7fbe0798975b8c1d60db2b2001 Mon Sep 17 00:00:00 2001 From: babymonkey1111 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 fb0861c..055a57b 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 c9c36ca..f7ab091 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 3cb0c21..41ad9e7 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,