Skip to content

Commit

Permalink
Drop Python 2, upgrade to Django 2.2+
Browse files Browse the repository at this point in the history
Drop support for python 2
Upgrade to support python 3.6, 3.7, 3.8, and 3.9
Upgrade to support Django 2.2, 3.0, 3.1, and 3.2
  • Loading branch information
lanshark committed Aug 24, 2021
1 parent 3794feb commit 34d878e
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 86 deletions.
66 changes: 28 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
#sudo: true
#before_install:
# - sudo apt-get update -qq
# - sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb
# - sudo apt-get install -qq libtiff4-dev libjpeg8-dev libfreetype6-dev liblcms1-dev libwebp-dev
# - sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip
# - sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev
# - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
#language: python
#cache:
# pip
#install:
# pip install -r dev-requirements.txt
#python:
# - "2.7"
# - "3.5"
# - "3.6"
#script:
# tox

sudo: true
before_install:
- sudo apt-get update -qq
Expand All @@ -35,28 +15,38 @@ before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
matrix:
include:
- python: 2.7
env: TOX_ENV=py27-django19
- python: 2.7
env: TOX_ENV=py27-django110
- python: 2.7
env: TOX_ENV=py27-django111
- python: 3.5
env: TOX_ENV=py35-django19
- python: 3.5
env: TOX_ENV=py35-django110
- python: 3.5
env: TOX_ENV=py35-django111
- python: 3.5
env: TOX_ENV=py35-django20
- python: 3.6
env: TOX_ENV=py36-django19
env: TOX_ENV=py36-django22
- python: 3.6
env: TOX_ENV=py36-django110
env: TOX_ENV=py36-django30
- python: 3.6
env: TOX_ENV=py36-django111
env: TOX_ENV=py36-django31
- python: 3.6
env: TOX_ENV=py36-django20
env: TOX_ENV=py36-django32
- python: 3.7
env: TOX_ENV=py37-django22
- python: 3.7
env: TOX_ENV=py37-django30
- python: 3.7
env: TOX_ENV=py37-django31
- python: 3.7
env: TOX_ENV=py37-django32
- python: 3.8
env: TOX_ENV=py38-django22
- python: 3.8
env: TOX_ENV=py38-django30
- python: 3.8
env: TOX_ENV=py38-django31
- python: 3.8
env: TOX_ENV=py38-django32
- python: 3.9
env: TOX_ENV=py39-django22
- python: 3.9
env: TOX_ENV=py39-django30
- python: 3.9
env: TOX_ENV=py39-django31
- python: 3.9
env: TOX_ENV=py39-django32

script: tox -e $TOX_ENV

Expand Down
11 changes: 1 addition & 10 deletions encrypted_model_fields/fields.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from __future__ import unicode_literals

import django.db
import django.db.models
from django.utils.six import PY2, string_types
from django.utils.functional import cached_property
from django.core import validators
from django.conf import settings
Expand Down Expand Up @@ -66,7 +63,7 @@ def to_python(self, value):
if value is None:
return value

if isinstance(value, (bytes, string_types[0])):
if isinstance(value, (bytes, str)):
if isinstance(value, bytes):
value = value.decode('utf-8')
try:
Expand All @@ -84,8 +81,6 @@ def get_db_prep_save(self, value, connection):

if value is None:
return value
if PY2:
return encrypt_str(unicode(value))
# decode the encrypted value to a unicode string, else this breaks in pgsql
return (encrypt_str(str(value))).decode('utf-8')

Expand Down Expand Up @@ -130,8 +125,6 @@ def get_db_prep_save(self, value, connection):
value = '1'
elif value is False:
value = '0'
if PY2:
return encrypt_str(unicode(value))
# decode the encrypted value to a unicode string, else this breaks in pgsql
return encrypt_str(str(value)).decode('utf-8')

Expand All @@ -145,8 +138,6 @@ def get_db_prep_save(self, value, connection):
value = '1'
elif value is False:
value = '0'
if PY2:
return encrypt_str(unicode(value))
# decode the encrypted value to a unicode string, else this breaks in pgsql
return encrypt_str(str(value)).decode('utf-8')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.core.management.base import BaseCommand
from django.utils.six import PY2

import cryptography.fernet

Expand All @@ -9,7 +8,4 @@ class Command(BaseCommand):

def handle(self, *args, **options):
key = cryptography.fernet.Fernet.generate_key()
if PY2:
self.stdout.write(key.decode())
else:
self.stdout.write(key.decode('utf-8'), ending='\n')
self.stdout.write(key.decode('utf-8'), ending='\n')
2 changes: 0 additions & 2 deletions encrypted_model_fields/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.test import TestCase
from django.core.exceptions import ImproperlyConfigured

Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r requirements.txt
-r base.txt

wheel

Expand Down
18 changes: 8 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
import os
Expand Down Expand Up @@ -34,9 +33,8 @@
maintainer="Scott Sharkey",
maintainer_email="[email protected]",
install_requires=[
'Django>=1.9',
'Django>=2.2',
'cryptography>=2.3',
'six',
],
tests_require=['tox'],
keywords=['encryption', 'django', 'fields', ],
Expand All @@ -52,15 +50,15 @@
'Topic :: Security',
'Topic :: System :: Systems Administration :: Authentication/Directory',
"Programming Language :: Python",
'Programming Language :: Python :: 2',
"Programming Language :: Python :: 2.7",
'Programming Language :: Python :: 3',
"Programming Language :: Python :: 3.5",
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Framework :: Django',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
],
)
2 changes: 0 additions & 2 deletions testapp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# -*- coding: utf-8 -*-

1 change: 0 additions & 1 deletion testapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.contrib import admin

# Register your models here.
3 changes: 0 additions & 3 deletions testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import encrypted_model_fields.fields

Expand Down
1 change: 0 additions & 1 deletion testapp/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import django.db.models

from encrypted_model_fields import fields
Expand Down
3 changes: 0 additions & 3 deletions testapp/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import datetime
import mock

Expand Down
4 changes: 0 additions & 4 deletions testapp/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


urlpatterns = []
14 changes: 8 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
[tox]
envlist = {py27}-django{111},{py35,py36}-django{111,20}
envlist = {py36,py37,py38,py39}-django{22,30,31,32}
install_command = pip install {opts} "{packages}"
recreate = true

[testenv]
basepython =
py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9

deps =
mock
django_coverage
django111: Django>=1.11,<1.12
django20: Django>=2.0,<2.1
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
django32: Django>=3.2,<3.3
setenv =
DJANGO_SETTINGS_MODULE = settings_test
commands=
python manage.py test

0 comments on commit 34d878e

Please sign in to comment.