Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remplacement de poetry par pipenv #116

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
PYTHONPATH: .
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.12"]
services:
postgres:
image: postgres:14-alpine
Expand All @@ -29,8 +29,8 @@ jobs:
- name: 🌍 Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --no-root
pip install pipenv --user
pipenv install --dev
- name: 📄 Copy empty .env.test to .env
run: |
cp .env.test .env
Expand All @@ -39,7 +39,7 @@ jobs:
make quality
- name: 🚧 Check pending migrations
run: |
poetry run django-admin makemigrations --check --dry-run --noinput
pipenv run django-admin makemigrations --check --dry-run --noinput
- name: 🤹‍ Run the unit tests
run: |
make test-unit
Expand Down
22 changes: 5 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,25 @@ ENV PYTHONUNBUFFERED=1
ENV GECKODRIVER_URL=https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux32.tar.gz
ENV APP_DIR="/app"

# Configure Poetry
ENV POETRY_VERSION=1.7.0
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Add new user to run the whole thing as non-root.
RUN set -ex \
&& addgroup app \
&& adduser --ingroup app --home ${APP_DIR} --disabled-password app;

# Install poetry separated from system interpreter
RUN python3 -m venv ${POETRY_VENV} \
&& ${POETRY_VENV}/bin/pip install -U pip setuptools \
&& ${POETRY_VENV}/bin/pip install poetry==${POETRY_VERSION}

# Add `poetry` to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

WORKDIR $APP_DIR

COPY pyproject.toml poetry.lock ./
RUN poetry install
COPY Pipfile Pipfile.lock ${PROJECT_DIR}/
RUN pip install pipenv --no-cache-dir \
&& pipenv install --system --deploy

COPY --chown=app:app . .

RUN poetry run python manage.py collectstatic --no-input --ignore=*.sass
RUN make init

USER app

ENTRYPOINT ["./entrypoint.sh"]

# https://stackoverflow.com/a/40454758/21676629
CMD ["sh", "-c", "poetry run python manage.py runserver 0.0.0.0:$HOST_PORT"]
CMD ["sh", "-c", "pipenv run python manage.py runserver 0.0.0.0:$HOST_PORT"]
45 changes: 28 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,64 @@ web-prompt:

.PHONY: test-unit
test-unit:
$(EXEC_CMD) poetry run python manage.py test --settings config.settings_test
$(EXEC_CMD) pipenv run python manage.py test --settings config.settings_test

.PHONY: collectstatic
collectstatic:
$(EXEC_CMD) poetry run python manage.py collectstatic --noinput --ignore=*.sass
$(EXEC_CMD) pipenv run python manage.py collectstatic --noinput --ignore=*.sass


.PHONY: messages
messages:
$(EXEC_CMD) poetry run django-admin makemessages -l fr --ignore=manage.py --ignore=medias --ignore=setup.py --ignore=staticfiles --ignore=templates
$(EXEC_CMD) pipenv run django-admin makemessages -l fr --ignore=manage.py --ignore=medias --ignore=setup.py --ignore=staticfiles --ignore=templates

.PHONY: sass
sass:
$(EXEC_CMD) poetry run python manage.py compilescss
$(EXEC_CMD) pipenv run python manage.py compilescss
make collectstatic

.PHONY: quality
quality:
$(EXEC_CMD) poetry run black --check --exclude=venv .
$(EXEC_CMD) poetry run isort --check --skip-glob="**/migrations" --extend-skip-glob="venv" .
$(EXEC_CMD) poetry run flake8 --count --show-source --statistics --exclude="venv,**/migrations" .
$(EXEC_CMD) pipenv run black --check --exclude=venv .
$(EXEC_CMD) pipenv run isort --check --skip-glob="**/migrations" --extend-skip-glob="venv" .
$(EXEC_CMD) pipenv run flake8 --count --show-source --statistics --exclude="venv,**/migrations" .

.PHONY: fix
fix:
$(EXEC_CMD) poetry run black --exclude=venv .
$(EXEC_CMD) poetry run isort --skip-glob="**/migrations" --extend-skip-glob="venv" .
$(EXEC_CMD) pipenv run black --exclude=venv .
$(EXEC_CMD) pipenv run isort --skip-glob="**/migrations" --extend-skip-glob="venv" .


.PHONY: dev-init
dev-init:
$(EXEC_CMD) pipenv sync --dev
$(EXEC_CMD) pipenv run pre-commit install

.PHONY: init
init:
$(EXEC_CMD) poetry install
$(EXEC_CMD) poetry run pre-commit install
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) pipenv sync
$(EXEC_CMD) pipenv run python manage.py migrate
make collectstatic
$(EXEC_CMD) pipenv run python manage.py set_config
$(EXEC_CMD) pipenv run python manage.py create_starter_pages

.PHONY: update
update:
$(EXEC_CMD) pipenv run python manage.py migrate
$(EXEC_CMD) pipenv run python manage.py update_index
$(EXEC_CMD) pipenv run python manage.py compilemessages
make collectstatic
$(EXEC_CMD) poetry run python manage.py set_config
$(EXEC_CMD) poetry run python manage.py create_starter_pages

.PHONY: demo
demo:
make init
$(EXEC_CMD) poetry run python manage.py create_demo_pages
$(EXEC_CMD) pipenv run python manage.py create_demo_pages

.PHONY: runserver
runserver:
$(EXEC_CMD) poetry run python manage.py runserver $(HOST_URL):$(HOST_PORT)
$(EXEC_CMD) pipenv run python manage.py runserver $(HOST_URL):$(HOST_PORT)


.PHONY: test
test:
$(EXEC_CMD) poetry run python manage.py test
$(EXEC_CMD) pipenv run python manage.py test
40 changes: 40 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "~=5.0.2"
wagtail = "~=6.0"
django-dsfr = "~=1.1.2"
psycopg2-binary = "~=2.9.9"
python-dotenv = "~=1.0.0"
dj-database-url = "~=2.1.0"
gunicorn = "~=22.0.0"
django-sass-processor = "~=1.3"
libsass = "~=0.22.0"
dj-static = "~=0.0.6"
wagtailmenus = "~=4.0"
wagtail-modeladmin = "~=2.0.0"
wagtail-markdown = "~=0.11.1"
unidecode = "~=1.3.8"
django-storages = {extras = ["s3"], version = "~=1.14.2"}
boto3 = "~=1.34.56"
beautifulsoup4 = "~=4.12.3"
django-taggit = "~=5.0.1"
wagtail-localize = "~=1.9"

[dev-packages]
black = "~=24.3.0"
flake8 = "~=6.1.0"
isort = "~=5.12.0"
pre-commit = "~=3.5.0"
djlint = "~=1.34.0"
django-extensions = "~=3.2.3"
ipython = "~=8.18.1"
libsass = "~=0.22.0"
django-compressor = "~=4.4"
faker = "~=24.3.0"

[requires]
python_version = "3.12"
Loading
Loading