From dcdcc72a9c5ad4b642c2ccb973d958d11f3e7fea Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:19:56 +0100 Subject: [PATCH 1/8] Revert "Revert "Pip install isntead of poetry"" This reverts commit 0adfa2a02e6c93615e1e01a8f674e21a6e62adcb. --- Dockerfile | 17 +++-------------- pyproject.toml | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index c1fadb8..2965478 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ FROM python:${PYTHON_VERSION} as python LABEL authors="piwero" ARG APP_HOME=/app - ENV PYTHONUNBUFFERED=1 \ # prevents python creating .pyc files PYTHONDONTWRITEBYTECODE=1 \ @@ -13,15 +12,8 @@ ENV PYTHONUNBUFFERED=1 \ # pip PIP_NO_CACHE_DIR=off \ PIP_DISABLE_PIP_VERSION_CHECK=on \ - PIP_DEFAULT_TIMEOUT=100 \ - \ - # poetry - # https://python-poetry.org/docs/configuration/#using-environment-variables - POETRY_VERSION=1.5.1 \ - POETRY_HOME="/opt/poetry" \ - POETRY_NO_INTERACTION=1 + PIP_DEFAULT_TIMEOUT=100 -ENV PATH="$POETRY_HOME/bin:$PATH" # Install apt packages RUN apt-get update && apt-get install --no-install-recommends -y \ @@ -31,15 +23,12 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* -RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/${POETRY_VERSION}/install-poetry.py | python - --version ${POETRY_VERSION} - WORKDIR ${APP_HOME} #copy poetry files -COPY poetry.lock pyproject.toml ./ +COPY pyproject.toml ./ -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi +RUN pip install . # copy application code to WORKDIR COPY . . \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index cd67287..340a7c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,5 +67,5 @@ exclude = [ line-length = 88 [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["setuptools>=40.8.0", "wheel"] +build-backend = "setuptools.build_meta:__legacy__" From c425bffcfa0dc697309cbc85c288c33d796be620 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:19:56 +0100 Subject: [PATCH 2/8] Revert "Revert "Update image for k8s without poetry"" This reverts commit 60404488bf67d63ecf20517a5ee19700f3ed0ff6. --- kubernetes/app/django/django-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/app/django/django-deployment.yaml b/kubernetes/app/django/django-deployment.yaml index bc8c8ad..27f51cf 100644 --- a/kubernetes/app/django/django-deployment.yaml +++ b/kubernetes/app/django/django-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: crud-auth-github - image: piwero/crud_auth_github:2.0 + image: piwero/crud_auth_github:3.0 imagePullPolicy: Always command: - "sh" From bef6a6bbfaaa4d452e42533094446824bdcae7b7 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:19:56 +0100 Subject: [PATCH 3/8] Revert "Revert "Update pyproject.toml to work without poetry"" This reverts commit 0c736997e42053a29ae15f310b4c4475b914e2f5. --- pyproject.toml | 63 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 340a7c9..784d8a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,37 +1,38 @@ -[tool.poetry] +[project] name = "crud-auth-github" version = "2" description = "" -authors = ["piwero "] +authors = [{name="piwero"}] readme = "README.md" +requires-python = ">=3.11" +dependencies = [ + "asgiref>=3.7.2", + "Django>=4.0.0", + "django-allauth>=0.54.0", + "django-crispy-forms>=1.14.0", + "dj-database-url>=2.0.0", + "gunicorn>=21.0.0", + "psycopg2-binary>=2.9.3", + "python-decouple>=3.6", + "sqlparse>=0.4.4", + "whitenoise>=6.2.0" +] - -[tool.poetry.dependencies] -asgiref = "^3.7.2" -Django = "^4.0.0" -django-allauth = "^0.54.0" -django-crispy-forms = "^1.14.0" -dj-database-url = "^2.0.0" -gunicorn = "^21.0.0" -psycopg2-binary = "^2.9.3" -python = "^3.10" -python-decouple = "^3.6" -sqlparse = "^0.4.4" -whitenoise = "^6.2.0" - -[tool.poetry.group.dev.dependencies] -black = "^23.3.0" -django-debug-toolbar = "^4.1.0" -django-extensions = "^3.2.3" -mypy = "^1.2.0" -ipdb = "^0.13.13" -isort = "^5.12.0" -pre-commit = "^3.2.2" -pytest = "^7.3.1" -pytest-cov = "^4.0.0" -pytest-django = "^4.5.2" -pytest-xdist = "^3.2.1" -ruff = "^0.0.291" +[project.optional-dependencies] +dev = [ + "black>=23.3.0", + "django-debug-toolbar>=4.1.0", + "django-extensions>=3.2.3", + "mypy>=1.2.0", + "ipdb>=0.13.13", + "isort>=5.12.0", + "pre-commit>=3.2.2", + "pytest>=7.3.1", + "pytest-cov>=4.0.0", + "pytest-django>=4.5.2", + "pytest-xdist>=3.2.1", + "ruff>=0.0.291" +] [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "core.settings.test_settings" @@ -67,5 +68,5 @@ exclude = [ line-length = 88 [build-system] -requires = ["setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta:__legacy__" +requires = ["setuptools>=63.0"] +build-backend = "setuptools.build_meta" From a82ec321afd45d68d2426c0a3d0db450c348d434 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:33:03 +0100 Subject: [PATCH 4/8] Fix ``` To avoid accidental inclusion of unwanted files or directories, setuptools will not proceed with this build. If you are trying to create a single distribution with multiple packages on purpose, you should not rely on automatic discovery. Instead, consider the following options: 1. set up custom discovery (`find` directive with `include` or `exclude`) 2. use a `src-layout` 3. explicitly set `py_modules` or `packages` with a list of names To find more information, look for "package discovery" on setuptools docs. [end of output] ``` --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 784d8a1..b7b006b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,8 @@ dev = [ "pytest-xdist>=3.2.1", "ruff>=0.0.291" ] +[tool.setuptools.packages] +find = {} [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "core.settings.test_settings" From 637025e2e4edea05c7ffd6a8f22f4ec7ed287d52 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:35:35 +0100 Subject: [PATCH 5/8] Remove .env use --- .github/workflows/python-app-pip.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/python-app-pip.yml b/.github/workflows/python-app-pip.yml index 2455db6..72964ab 100644 --- a/.github/workflows/python-app-pip.yml +++ b/.github/workflows/python-app-pip.yml @@ -30,7 +30,6 @@ jobs: - name: Run linters run: | - source .venv/bin/activate ruff . black . @@ -41,6 +40,5 @@ jobs: GH_CLIENT_ID: "###" GH_CLIENT_SECRET: "###" run: | - source .venv/bin/activate python manage.py collectstatic pytest --cov=. -n auto # Run tests with coverage and in parallel From bdd3f25e23ecaf017a44efd4533e45dcda1bbfe3 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:40:20 +0100 Subject: [PATCH 6/8] Update GH action name --- .github/workflows/python-app-poetry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app-poetry.yml b/.github/workflows/python-app-poetry.yml index d7d3102..c3cfdb0 100644 --- a/.github/workflows/python-app-poetry.yml +++ b/.github/workflows/python-app-poetry.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application +name: Python application with Poetry on: push: From 50eedae7d8c12787ed19521cfcf0560770b8fed4 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 08:44:33 +0100 Subject: [PATCH 7/8] Install dev dependencies --- .github/workflows/python-app-pip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app-pip.yml b/.github/workflows/python-app-pip.yml index 72964ab..3a4b15c 100644 --- a/.github/workflows/python-app-pip.yml +++ b/.github/workflows/python-app-pip.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | - pip install . + pip install ".[dev]" - name: Run linters run: | From fc03742c5a10be806ee123c5e9e5221b07463856 Mon Sep 17 00:00:00 2001 From: Nacho Pinero Date: Wed, 27 Sep 2023 10:18:39 +0100 Subject: [PATCH 8/8] Tag specific version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b7b006b..358f1a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires-python = ">=3.11" dependencies = [ "asgiref>=3.7.2", "Django>=4.0.0", - "django-allauth>=0.54.0", + "django-allauth==0.54.0", "django-crispy-forms>=1.14.0", "dj-database-url>=2.0.0", "gunicorn>=21.0.0",