Python 3.6, 3.9 and Django 3.0 compatibility

This commit is contained in:
Swen Kooij 2020-01-06 15:46:40 +01:00
parent 53d7cd0c66
commit 49d88af76a
11 changed files with 120 additions and 46 deletions

View File

@ -1,5 +1,32 @@
version: 2 version: 2
jobs: jobs:
test-python36:
docker:
- image: python:3.6-alpine
- image: postgres:11.0
environment:
POSTGRES_DB: 'localizedfields'
POSTGRES_USER: 'localizedfields'
POSTGRES_PASSWORD: 'localizedfields'
steps:
- checkout
- run:
name: Install packages
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
- run:
name: Install Python packages
command: pip install --progress-bar off .[test]
- run:
name: Run tests
command: tox -e 'py36-dj{20,21,22,30}'
environment:
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
- store_test_results:
path: reports
test-python37: test-python37:
docker: docker:
- image: python:3.7-alpine - image: python:3.7-alpine
@ -16,7 +43,7 @@ jobs:
- run: - run:
name: Install Python packages name: Install Python packages
command: pip install -r requirements/test.txt command: pip install --progress-bar off .[test]
- run: - run:
name: Run tests name: Run tests
@ -43,7 +70,7 @@ jobs:
- run: - run:
name: Install Python packages name: Install Python packages
command: pip install -r requirements/test.txt command: pip install --progress-bar off .[test]
- run: - run:
name: Run tests name: Run tests
@ -54,6 +81,33 @@ jobs:
- store_test_results: - store_test_results:
path: reports path: reports
test-python39:
docker:
- image: python:3.9-rc-alpine3.10
- image: postgres:11.0
environment:
POSTGRES_DB: 'localizedfields'
POSTGRES_USER: 'localizedfields'
POSTGRES_PASSWORD: 'localizedfields'
steps:
- checkout
- run:
name: Install packages
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
- run:
name: Install Python packages
command: pip install --progress-bar off .[test]
- run:
name: Run tests
command: tox -e 'py39-dj{21,22,30}'
environment:
DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields'
- store_test_results:
path: reports
analysis: analysis:
docker: docker:
- image: python:3.7-alpine - image: python:3.7-alpine
@ -65,7 +119,7 @@ jobs:
- run: - run:
name: Install Python packages name: Install Python packages
command: pip install -r requirements/analysis.txt command: pip install --progress-bar off .[analysis]
- run: - run:
name: Verify formatting / linting name: Verify formatting / linting
@ -76,6 +130,8 @@ workflows:
version: 2 version: 2
build: build:
jobs: jobs:
- test-python36
- test-python37 - test-python37
- test-python38 - test-python38
- test-python39
- analysis - analysis

View File

@ -4,7 +4,7 @@
| :memo: | **License** | [![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org) | | :memo: | **License** | [![License](https://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org) |
| :package: | **PyPi** | [![PyPi](https://badge.fury.io/py/django-localized-fields.svg)](https://pypi.python.org/pypi/django-localized-fields) | | :package: | **PyPi** | [![PyPi](https://badge.fury.io/py/django-localized-fields.svg)](https://pypi.python.org/pypi/django-localized-fields) |
| <img src="https://icon-library.net/images/django-icon/django-icon-0.jpg" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0 | | <img src="https://icon-library.net/images/django-icon/django-icon-0.jpg" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0 |
| <img src="http://www.iconarchive.com/download/i73027/cornmanthe3rd/plex/Other-python.ico" width="22px" height="22px" align="center" /> | **Python Versions** | 3.7, 3.8 | | <img src="http://www.iconarchive.com/download/i73027/cornmanthe3rd/plex/Other-python.ico" width="22px" height="22px" align="center" /> | **Python Versions** | 3.6, 3.7, 3.8 |
| :book: | **Documentation** | [Read The Docs](https://django-localized-fields.readthedocs.io) | | :book: | **Documentation** | [Read The Docs](https://django-localized-fields.readthedocs.io) |
| :warning: | **Upgrade** | [Upgrade fom v5.x](https://django-localized-fields.readthedocs.io/en/latest/releases.html#v6-0) | :warning: | **Upgrade** | [Upgrade fom v5.x](https://django-localized-fields.readthedocs.io/en/latest/releases.html#v6-0)
| :checkered_flag: | **Installation** | [Installation Guide](https://django-localized-fields.readthedocs.io/en/latest/installation.html) | | :checkered_flag: | **Installation** | [Installation Guide](https://django-localized-fields.readthedocs.io/en/latest/installation.html) |
@ -22,13 +22,13 @@
* PostgreSQL 10 or newer. * PostgreSQL 10 or newer.
* Django 2.0 or newer. * Django 2.0 or newer.
* Python 3.7 or newer. * Python 3.6 or newer.
### Getting started ### Getting started
1. Clone the repository: 1. Clone the repository:
λ git clone https://github.com/SectorLabs/django-localized-fields.git λ git clone https://github.com/SectorLabs/django-localized-fields.git
2. Create a virtual environment: 2. Create a virtual environment:
@ -47,8 +47,7 @@
4. Install the development/test dependencies: 4. Install the development/test dependencies:
λ pip install -r requirements/test.txt λ pip install .[test] .[analysis]
λ pip install -r requirements/analysis.txt
5. Run the tests: 5. Run the tests:

View File

@ -3,7 +3,7 @@ Welcome
``django-localized-fields`` is a Django library that provides fields to store localized content (content in various languages) in a PostgreSQL database. It does this by utilizing the PostgreSQL ``hstore`` type, which is available in Django as ``HStoreField`` since Django 1.10. ``django-localized-fields`` is a Django library that provides fields to store localized content (content in various languages) in a PostgreSQL database. It does this by utilizing the PostgreSQL ``hstore`` type, which is available in Django as ``HStoreField`` since Django 1.10.
This package requires Python 3.7 or newer, Django 2.0 or newer and PostgreSQL 10 or newer. This package requires Python 3.6 or newer, Django 2.0 or newer and PostgreSQL 10 or newer.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2

View File

@ -1,7 +1,4 @@
import bleach
from django.conf import settings from django.conf import settings
from django_bleach.utils import get_bleach_default_options
from .field import LocalizedField from .field import LocalizedField
@ -22,6 +19,20 @@ class LocalizedBleachField(LocalizedField):
to the database or an update. to the database or an update.
""" """
# the bleach library vendors dependencies and the html5lib
# dependency is incompatible with python 3.9, until that's
# fixed, you cannot use LocalizedBleachField with python 3.9
# sympton:
# ImportError: cannot import name 'Mapping' from 'collections'
try:
import bleach
from django_bleach.utils import get_bleach_default_options
except ImportError:
raise UserWarning(
"LocalizedBleachField is not compatible with Python 3.9 yet."
)
localized_value = getattr(instance, self.attname) localized_value = getattr(instance, self.attname)
if not localized_value: if not localized_value:
return None return None

View File

@ -1,8 +0,0 @@
-r base.txt
black==19.3b0
flake8==3.7.7
autoflake==1.3
autopep8==1.4.4
isort==4.3.20
sl-docformatter==1.4

View File

@ -1 +0,0 @@
-e .

View File

@ -1,2 +0,0 @@
Sphinx==2.2.0
sphinx-rtd-theme==0.4.3

View File

@ -1,14 +0,0 @@
-r base.txt
# Tests
coverage==4.4.2
tox==2.9.1
pytest==5.2.1
pytest-django==3.6.0
pytest-cov==2.8.1
# Test support
dj-database-url==0.4.2
django-autoslug==1.9.3
django-bleach==0.3.0
psycopg2==2.8.4

View File

@ -36,7 +36,7 @@ with open(
setup( setup(
name="django-localized-fields", name="django-localized-fields",
version="6.0b1", version="6.0b2",
packages=find_packages(exclude=["tests"]), packages=find_packages(exclude=["tests"]),
include_package_data=True, include_package_data=True,
license="MIT License", license="MIT License",
@ -62,16 +62,38 @@ setup(
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: MIT License",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6",
"Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
], ],
python_requires=">=3.7", python_requires=">=3.6",
install_requires=[ install_requires=[
"Django>=2.0", "Django>=2.0",
"django-postgres-extra>=2.0a7,<3.0", "django-postgres-extra>=2.0a14,<3.0",
"deprecation==2.0.7", "deprecation==2.0.7",
], ],
extras_require={
':python_version <= "3.6"': ["dataclasses"],
"docs": ["Sphinx==2.2.0", "sphinx-rtd-theme==0.4.3"],
"test": [
"tox==3.14.3",
"pytest==5.3.2",
"pytest-django==3.7.0",
"pytest-cov==2.8.1",
"dj-database-url==0.5.0",
"django-autoslug==1.9.6",
"django-bleach==0.6.1",
"psycopg2==2.8.4",
],
"analysis": [
"black==19.3b0",
"flake8==3.7.7",
"autoflake==1.3",
"autopep8==1.4.4",
"isort==4.3.20",
"sl-docformatter==1.4",
],
},
cmdclass={ cmdclass={
"lint": create_command( "lint": create_command(
"Lints the code", "Lints the code",

View File

@ -1,12 +1,23 @@
import bleach """isort:skip_file."""
import sys
import pytest
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
from django_bleach.utils import get_bleach_default_options
from localized_fields.fields import LocalizedBleachField from localized_fields.fields import LocalizedBleachField
from localized_fields.value import LocalizedValue from localized_fields.value import LocalizedValue
try:
import bleach
from django_bleach.utils import get_bleach_default_options
except ImportError:
if sys.version_info >= (3, 9):
pytest.skip("feature not ready for python 3.9", allow_module_level=True)
class ModelTest: class ModelTest:
"""Used to declare a bleach-able field on.""" """Used to declare a bleach-able field on."""

View File

@ -1,13 +1,13 @@
[tox] [tox]
envlist = py37-dj{20,21,22,30}, py38-dj{20,21,22,30} envlist = py36-dj{20,21,22,30}, py37-dj{20,21,22,30}, py38-dj{20,21,22,30}, py39-dj{21,22,30}
[testenv] [testenv]
deps = deps =
dj20: Django>=2.0,<2.1 dj20: Django>=2.0,<2.1
dj21: Django>=2.1,<2.2 dj21: Django>=2.1,<2.2
dj22: Django>=2.2,<2.3 dj22: Django>=2.2,<2.3
dj30: Django>=3.0a1,<3.1 dj30: Django>=3.0,<3.0.2
-rrequirements/test.txt .[test]
setenv = setenv =
DJANGO_SETTINGS_MODULE=settings DJANGO_SETTINGS_MODULE=settings
passenv = DATABASE_URL passenv = DATABASE_URL