Skip to content
Snippets Groups Projects
Commit cc35443b authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Bump to Python 3.8

parent f1e2f6a5
No related branches found
No related tags found
1 merge request!1547Bump to Python 3.8
...@@ -11,7 +11,7 @@ include: ...@@ -11,7 +11,7 @@ include:
# For jobs that run backend scripts directly # For jobs that run backend scripts directly
.backend-setup: .backend-setup:
image: registry.gitlab.com/arkindex/backend/base:django-3.2.6 image: registry.gitlab.com/arkindex/backend/base:python-3.8
cache: cache:
paths: paths:
...@@ -65,7 +65,7 @@ backend-tests: ...@@ -65,7 +65,7 @@ backend-tests:
- codecov - codecov
backend-lint: backend-lint:
image: python:3.7 image: python:3.8
stage: test stage: test
except: except:
......
...@@ -34,6 +34,3 @@ repos: ...@@ -34,6 +34,3 @@ repos:
- repo: meta - repo: meta
hooks: hooks:
- id: check-useless-excludes - id: check-useless-excludes
default_language_version:
python: python3.7
FROM registry.gitlab.com/arkindex/backend/base:django-3.2.6 as build FROM registry.gitlab.com/arkindex/backend/base:python-3.8 as build
RUN mkdir build RUN mkdir build
ADD . build ADD . build
RUN cd build && python3 setup.py sdist RUN cd build && python3 setup.py sdist
FROM registry.gitlab.com/arkindex/backend/base:django-3.2.6 FROM registry.gitlab.com/arkindex/backend/base:python-3.8
ARG PONOS_BRANCH=master ARG PONOS_BRANCH=master
ARG PONOS_ID=10017043 ARG PONOS_ID=10017043
ARG TRANSKRIBUS_BRANCH=master ARG TRANSKRIBUS_BRANCH=master
......
FROM python:3.7-slim AS compilation FROM python:3.8-slim AS compilation
RUN apt-get update && apt-get install --no-install-recommends -y build-essential wget RUN apt-get update && apt-get install --no-install-recommends -y build-essential wget
...@@ -61,7 +61,7 @@ RUN python -m nuitka \ ...@@ -61,7 +61,7 @@ RUN python -m nuitka \
arkindex/manage.py arkindex/manage.py
# Start over from a clean setup # Start over from a clean setup
FROM registry.gitlab.com/arkindex/backend/base:django-3.2.6 as build FROM registry.gitlab.com/arkindex/backend/base:python-3.8 as build
# Import files from compilation # Import files from compilation
RUN mkdir /usr/share/arkindex RUN mkdir /usr/share/arkindex
......
import os.path import os.path
import sys
import yaml import yaml
from django.core.checks import Error, Warning, register from django.core.checks import Critical, Error, Warning, register
from ponos.recipe import parse_recipe from ponos.recipe import parse_recipe
...@@ -163,3 +164,15 @@ def public_hostname_check(*args, **kwargs): ...@@ -163,3 +164,15 @@ def public_hostname_check(*args, **kwargs):
id='arkindex.W008', id='arkindex.W008',
)] )]
return [] return []
@register()
def python_version_check(*args, **kwargs):
if sys.version_info.minor < 8:
return [
Critical(
'Arkindex requires Python 3.8 or later.',
id='arkindex.C001',
)
]
return []
...@@ -2,7 +2,7 @@ from pathlib import Path ...@@ -2,7 +2,7 @@ from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from django.conf import settings from django.conf import settings
from django.core.checks import Error, Warning from django.core.checks import Critical, Error, Warning
from django.test import TestCase, override_settings from django.test import TestCase, override_settings
from django.urls import path from django.urls import path
...@@ -180,3 +180,21 @@ class ChecksTestCase(TestCase): ...@@ -180,3 +180,21 @@ class ChecksTestCase(TestCase):
settings.PUBLIC_HOSTNAME = 'https://darkindex.lol' settings.PUBLIC_HOSTNAME = 'https://darkindex.lol'
self.assertListEqual(public_hostname_check(), []) self.assertListEqual(public_hostname_check(), [])
@patch('arkindex.project.checks.sys.version_info')
def test_python_version_check(self, version_info_mock):
from arkindex.project.checks import python_version_check
version_info_mock.minor = 7
self.assertListEqual(python_version_check(), [
Critical(
'Arkindex requires Python 3.8 or later.',
id='arkindex.C001',
)
])
version_info_mock.minor = 8
self.assertListEqual(python_version_check(), [])
version_info_mock.minor = 9
self.assertListEqual(python_version_check(), [])
...@@ -76,17 +76,20 @@ class BulkMap(Sized, Iterable): ...@@ -76,17 +76,20 @@ class BulkMap(Sized, Iterable):
assert isinstance(iterable, Sized), 'iterable must implement __len__' assert isinstance(iterable, Sized), 'iterable must implement __len__'
self.func = func self.func = func
self.iterable = iterable self.iterable = iterable
self._cached_length = None
def __getitem__(self, key): def __getitem__(self, key):
assert isinstance(key, slice), 'BulkMap only supports slicing' assert isinstance(key, slice), 'BulkMap only supports slicing'
return BulkMap(self.func, self.iterable[key]) return BulkMap(self.func, self.iterable[key])
def __len__(self): def __len__(self):
# Proxy __len__ without calling the function if self._cached_length is None:
if hasattr(self.iterable, 'count'): # Proxy __len__ without calling the function
return self.iterable.count() if hasattr(self.iterable, 'count'):
else: self._cached_length = self.iterable.count()
return len(self.iterable) else:
self._cached_length = len(self.iterable)
return self._cached_length
def __iter__(self): def __iter__(self):
return iter(self.func(list(self.iterable))) return iter(self.func(list(self.iterable)))
......
...@@ -90,10 +90,10 @@ INSERT INTO "documents_elementpath" ("id", ...@@ -90,10 +90,10 @@ INSERT INTO "documents_elementpath" ("id",
"element_id", "element_id",
"path", "path",
"ordering") "ordering")
VALUES ('{paths_ids[4]}'::uuid, '{children_ids[3]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 0), VALUES ('{paths_ids[4]}'::uuid, '{children_ids[0]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 2),
('{paths_ids[5]}'::uuid, '{children_ids[2]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 1), ('{paths_ids[5]}'::uuid, '{children_ids[2]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 1),
('{paths_ids[6]}'::uuid, '{children_ids[1]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 0), ('{paths_ids[6]}'::uuid, '{children_ids[3]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 0),
('{paths_ids[7]}'::uuid, '{children_ids[0]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 2), ('{paths_ids[7]}'::uuid, '{source_id}'::uuid, ARRAY['{destination_id}'::uuid]::uuid[], 3),
('{paths_ids[8]}'::uuid, '{source_id}'::uuid, ARRAY['{destination_id}'::uuid]::uuid[], 3); ('{paths_ids[8]}'::uuid, '{children_ids[1]}'::uuid, ARRAY['{destination_id}'::uuid,'{source_id}'::uuid]::uuid[], 0);
RELEASE SAVEPOINT "{savepoints[1]}" RELEASE SAVEPOINT "{savepoints[1]}"
FROM python:3.7-slim FROM python:3.8-slim
# Install some runtime deps and python dependencies that are slow to install or require specific build deps # Install some runtime deps and python dependencies that are slow to install or require specific build deps
ADD requirements.txt bootstrap.sh / ADD requirements.txt bootstrap.sh /
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment