Migrate to poetry

parent 711d1885
[flake8]
exclude = */migrations/*,*/urls.py
...@@ -6,7 +6,7 @@ variables: ...@@ -6,7 +6,7 @@ variables:
# https://github.com/thaliawww/python-thalia # https://github.com/thaliawww/python-thalia
# Should get auto-updated with the official 'python' repository # Should get auto-updated with the official 'python' repository
# Installs: # Installs:
# - pip: tox, coverage, pipenv # - pip: coverage, poetry
# - apt: ghostscript # - apt: ghostscript
PY36_IMAGE: thalia/python-thalia:3.6 PY36_IMAGE: thalia/python-thalia:3.6
PY37_IMAGE: thalia/python-thalia:3.7 PY37_IMAGE: thalia/python-thalia:3.7
...@@ -19,8 +19,10 @@ stages: ...@@ -19,8 +19,10 @@ stages:
codestyle: codestyle:
stage: test stage: test
image: $PY36_IMAGE image: $PY36_IMAGE
before_script:
- poetry install --no-interaction
script: script:
- tox -e flake8 - poetry run flake8 website
# Check for obsolete translations in .po files (starting with `#~`). # Check for obsolete translations in .po files (starting with `#~`).
- cd website - cd website
- grep --include="*.po" --files-with-matches --recursive "^#~" && exit 1 || echo "No obsolete translations found." - grep --include="*.po" --files-with-matches --recursive "^#~" && exit 1 || echo "No obsolete translations found."
...@@ -37,40 +39,42 @@ codestyle: ...@@ -37,40 +39,42 @@ codestyle:
- postgres:latest - postgres:latest
before_script: before_script:
- git log -1 - git log -1
- poetry install --no-interaction
script: script:
- tox -e ${PYTHON_VERSION}-${DJANGO_VERSION}
- cd website - cd website
- poetry run python manage.py check
- poetry run python manage.py templatecheck --project-only
- poetry run python manage.py makemigrations --no-input --check --dry-run
- >
poetry run
python -Wall -mcoverage run
--omit="manage.py,thaliawebsite/wsgi.py,*/migrations/*"
--branch
--source '.'
manage.py test
- coverage report - coverage report
python36-django21: python36-django21:
<<: *djangotest <<: *djangotest
image: $PY36_IMAGE image: $PY36_IMAGE
variables:
PYTHON_VERSION: py36
DJANGO_VERSION: django21
python37-django21: python37-django21:
<<: *djangotest <<: *djangotest
image: $PY37_IMAGE image: $PY37_IMAGE
variables:
PYTHON_VERSION: py37
DJANGO_VERSION: django21
docs: docs:
stage: test stage: test
image: $PY36_IMAGE image: $PY36_IMAGE
before_script: before_script:
# install django deps # install django deps
- pipenv --bare install --dev --ignore-pipfile - poetry install --no-interaction --extras "docs"
# install doc deps
- cd docs
- pipenv run pip install -r requirements.txt
script: script:
- echo "Building current docs" - echo "Building current docs"
- env -u GITLAB_CI pipenv run make doctest - cd docs
- env -u GITLAB_CI pipenv run sphinx-build -W . _build - env -u GITLAB_CI poetry run make doctest
- env -u GITLAB_CI poetry run sphinx-build -W . _build
- echo "Checking if there are changes" - echo "Checking if there are changes"
- pipenv run ./generate-apidocs.sh - poetry run ./generate-apidocs.sh
- git diff --exit-code - git diff --exit-code
build docker image: build docker image:
......
...@@ -37,21 +37,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ...@@ -37,21 +37,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ghostscript && \ ghostscript && \
rm -rf /var/lib/apt rm -rf /var/lib/apt
RUN pip install --no-cache-dir pipenv RUN pip install --no-cache-dir poetry && \
poetry config settings.virtualenvs.create false
WORKDIR /usr/src/app/website/ WORKDIR /usr/src/app/website/
# install python requirements # install python requirements
COPY docs/requirements.txt /usr/src/app/docs/ COPY pyproject.toml /usr/src/app/website/
COPY Pipfile /usr/src/app/website/ COPY poetry.lock /usr/src/app/website/
COPY Pipfile.lock /usr/src/app/website/
RUN if [ "$install_dev_requirements" -eq 1 ]; then \ RUN if [ "$install_dev_requirements" -eq 1 ]; then \
pipenv install --system --dev; \ poetry install --no-interaction --extras "docs"; \
else \ else \
echo "This will fail if the dependencies are out of date"; \ echo "This will fail if the dependencies are out of date"; \
pipenv install --system --deploy; \ poetry install --no-interaction --extras "docs" --no-dev; \
fi fi; \
RUN pip install --no-cache-dir \ poetry cache:clear --all --no-interaction pypi
-r ../docs/requirements.txt
# Create entry points # Create entry points
COPY resources/entrypoint.sh /usr/local/bin/entrypoint.sh COPY resources/entrypoint.sh /usr/local/bin/entrypoint.sh
......
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django-localflavor = "*"
freezegun = "*"
bleach = "*"
"django-tinymce4-lite" = "*"
rcssmin = "*"
djangorestframework = "*"
django-ical = "*"
django-libsass = "*"
django-cors-headers = "*"
python-magic = "*"
redis = "*"
Django = ">=2.1,<2.2"
Pillow = "*"
django_compressor = "*"
"psycopg2-binary" = "*"
bcrypt = "*"
"argon2_cffi" = "*"
uWSGI = "*"
"django-bootstrap4" = "*"
firebase-admin = "*"
sentry-sdk = "*"
django-sendfile2 = "*"
[dev-packages]
django-template-check = "*"
"flake8" = "*"
pydenticon = "*"
pylint = "*"
pylint-django = "*"
tox = "*"
Faker = "*"
factory_boy = "*"
coverage = "*"
This diff is collapsed.
...@@ -11,10 +11,11 @@ Getting started ...@@ -11,10 +11,11 @@ Getting started
If you use Docker, please look at [this part](#docker) of the README. If you use Docker, please look at [this part](#docker) of the README.
0. Get at least Python 3.6 and install pipenv and the Pillow requirements as per below. 0. Get at least Python 3.6 and install poetry and the Pillow requirements as per below.
1. Clone this repository 1. Clone this repository
2. Run `pipenv install --python 3 --dev` 2. Make sure `poetry` uses your python 3 installation: `poetry env use python3`
3. Run `pipenv shell` 3. Run `poetry install`
4. Run `poetry shell`
5. `cd website` 5. `cd website`
6. `./manage.py migrate` to initialise the database 6. `./manage.py migrate` to initialise the database
7. `./manage.py createsuperuser` to create the first user (note that this user won't be a member!) 7. `./manage.py createsuperuser` to create the first user (note that this user won't be a member!)
...@@ -23,23 +24,27 @@ If you use Docker, please look at [this part](#docker) of the README. ...@@ -23,23 +24,27 @@ If you use Docker, please look at [this part](#docker) of the README.
Testing and linting Testing and linting
------------------- -------------------
1. In the root folder of the project, run `tox`. You can use [`pyenv`](https://github.com/pyenv/pyenv) (on Unix systems) to test in different python
environments.
You may get errors about missing interpreters. That is normal and can be The linter can be run in the `poetry shell` or by running
ignored. If you want to run a specific check, you can do the following:
tox -e flake8 # Runs the flake8 linter poetry run flake8 website
tox -e py36-django20 # runs the tests with python 3.6 and Django 2.0
tox -e py37-django20 # runs the tests with python 3.7 and Django 2.0
You can run `tox -l` to see the available environments. There are a range of tests that can be run:
Pipenv poetry run python manage.py check
poetry run python manage.py templatecheck --project-only
poetry run python manage.py makemigrations --no-input --check --dry-run
poetry run python -mcoverage run --branch --source '.' manage.py test
coverage report
poetry
------ ------
Install Pipenv per the [pipenv documentation][pipenv install] Install poetry per the [poetry documentation][poetry install]
[pipenv install]: https://docs.pipenv.org/install/#installing-pipenv [poetry install]: https://github.com/sdispater/poetry#installation
Pillow dependencies Pillow dependencies
------------------- -------------------
......
recommonmark
sphinx==1.8.3
This diff is collapsed.
[tool.poetry]
name = "concrexit"
version = "22.0.0"
description = "New new Thalia website, now with extra Django."
authors = ["Thalia Technicie <www@thalia.nu>"]
license = "AGPL-3.0-or-later"
[tool.poetry.dependencies]
python = "^3.6"
django-localflavor = "^2.1"
freezegun = "^0.3.11"
bleach = "^3.1"
django-tinymce4-lite = "^1.7"
rcssmin = "^1.0"
djangorestframework = "^3.9"
django-ical = "^1.5"
django-libsass = "^0.7.0"
django-cors-headers = "^2.4"
python-magic = "^0.4.15"
redis = "^3.2"
Django = "^2.1"
Pillow = "^5.4"
django_compressor = "^2.2"
psycopg2-binary = "^2.7"
bcrypt = "^3.1"
argon2_cffi = "^19.1"
uWSGI = "^2.0"
django-bootstrap4 = "^0.0.7"
firebase-admin = "^2.15"
sentry-sdk = "^0.7.3"
django-sendfile2 = "^0.4.2"
# docs requirements
recommonmark = { version = "^0.5.0", optional = true }
sphinx = { version = "^1.8", optional = true }
[tool.poetry.extras]
docs = ["recommonmark", "sphinx"]
[tool.poetry.dev-dependencies]
django-template-check = "^0.3.1"
flake8 = "^3.7"
pydenticon = "^0.3.1"
pylint = "^2.2"
pylint-django = "^2.0"
Faker = "^1.0"
factory_boy = "^2.11"
coverage = "^4.5"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
[tox]
envlist = flake8, {py36,py37}-django21
skipsdist = True
skip_missing_interpreters = True
[testenv]
changedir={toxinidir}/website
commands =
; Copy the env list to make not conflict with the Django version
; specified below
pipenv --bare install --dev --ignore-pipfile
; override using pip. Using pipenv would write to Pipfile!
django21: pip install --pre 'django>=2.1rc1,<2.2'
pipenv --bare run python manage.py check
pipenv --bare run python manage.py templatecheck --project-only
pipenv --bare run python manage.py makemigrations --no-input --check --dry-run
pipenv --bare run python -Wall -mcoverage run --branch --source '.' manage.py test
pipenv --bare check
deps =
pipenv
passenv =
GITLAB_CI
PIP_CACHE_DIR
env =
PIPENV_SUPPRESS_NESTED_WARNING=1
[testenv:flake8]
basepython=python3.6
deps= flake8
skip_install=True
commands=
flake8 .
passenv =
PIP_CACHE_DIR
# Settings for Flake8
[flake8]
exclude = */migrations/*, */urls.py, .ropeproject
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment