Skip to content

Commit

Permalink
Added Django 2.2 & 3.0 to testing matrix (with fixes). Bumped Python …
Browse files Browse the repository at this point in the history
…version to 3.7.
  • Loading branch information
David Krauth committed Jul 17, 2020
1 parent bc251f4 commit ce04202
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build
ghostdriver.log
test/media
dist/
.python-version
18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ matrix:
- { python: 2.7, env: S3=0 TOXENV=py27-dj111 }
- { python: 2.7, env: S3=1 TOXENV=py27-dj111 }
- { python: 2.7, env: S3=0 TOXENV=py27-dj111-grp }
- { python: 3.6, env: S3=0 TOXENV=py36-dj111 }
- { python: 3.6, env: S3=0 TOXENV=py36-dj20 }
- { python: 3.6, env: S3=1 TOXENV=py36-dj20 }
- { python: 3.6, env: S3=0 TOXENV=py36-dj20-grp }
- { python: 3.6, env: S3=0 TOXENV=py36-dj21 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj111 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj20 }
- { python: 3.7, env: S3=1 TOXENV=py37-dj20 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj20-grp }
- { python: 3.7, env: S3=0 TOXENV=py37-dj21 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj22 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj22-grp }
- { python: 3.7, env: S3=0 TOXENV=py37-dj30 }
- { python: 3.7, env: S3=0 TOXENV=py37-dj30-grp }
allow_failures:
- env: S3=0 TOXENV=py36-dj21
- env:
S3=0 TOXENV=py37-dj30
S3=0 TOXENV=py37-dj30-grp

cache: pip

Expand Down
2 changes: 1 addition & 1 deletion cropduster/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.12.8'
__version__ = '4.12.9'
6 changes: 3 additions & 3 deletions cropduster/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import copy
import errno

import six
from six.moves import xrange

try:
from django.urls import get_urlconf, get_resolver
except ImportError:
from django.core.urlresolvers import get_urlconf, get_resolver
from django.http import HttpResponse
from django.utils.safestring import mark_safe
from django.utils import six
from django.utils.six.moves import xrange

from django.utils.encoding import force_text


Expand Down
2 changes: 1 addition & 1 deletion cropduster/fields.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import contextlib
from operator import attrgetter

import six
import django
from django import forms
from django.db import models, transaction, router, DEFAULT_DB_ALIAS
from django.db.models.fields import Field
from django.db.models.fields.files import ImageFileDescriptor, ImageFieldFile
from django.db.models.fields.related import ManyToManyRel, ManyToManyField
from django.utils.functional import cached_property
from django.utils import six
from django.contrib.contenttypes.models import ContentType

from generic_plus.fields import GenericForeignFileField
Expand Down
5 changes: 3 additions & 2 deletions cropduster/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import re
import hashlib

from six.moves.urllib import parse as urlparse
from six.moves.urllib.request import urlopen

from django.core.files.images import get_image_dimensions
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files.storage import default_storage
from django.conf import settings
from django.db.models.fields.files import FieldFile, FileField
from django.utils.functional import cached_property
from django.utils.http import urlunquote_plus
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.six.moves.urllib.request import urlopen

from generic_plus.utils import get_relative_media_url, get_media_path

Expand Down
2 changes: 1 addition & 1 deletion cropduster/forms.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import six
from django import forms
from django.core.exceptions import ValidationError
from django.forms.models import ModelChoiceIterator
from django.forms.models import ChoiceField, ModelMultipleChoiceField
from django.forms.utils import flatatt
from django.utils.encoding import force_text
from django.utils.html import escape, conditional_escape
from django.utils import six

from generic_plus.forms import BaseGenericFileInlineFormSet, GenericForeignFileWidget

Expand Down
10 changes: 5 additions & 5 deletions cropduster/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import time
from datetime import datetime

import six
from six.moves import xrange

from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.core.files.storage import FileSystemStorage
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import connection, models
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six.moves import xrange
from django.core.files.storage import default_storage, FileSystemStorage

import PIL.Image
Expand Down Expand Up @@ -44,7 +44,7 @@ def safe_str_path(file_path):
return file_path


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class Thumb(models.Model):

name = models.CharField(max_length=255, db_index=True)
Expand Down Expand Up @@ -213,7 +213,7 @@ def generate_filename(instance, filename):
return filename


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class Image(models.Model):

content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
Expand Down
9 changes: 4 additions & 5 deletions cropduster/resizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import hashlib
import tempfile

import six
from six.moves import filter
import PIL.Image

from django.core.exceptions import ImproperlyConfigured
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six.moves import filter
from django.core.files.storage import default_storage

from .settings import CROPDUSTER_RETAIN_METADATA
Expand All @@ -23,7 +22,7 @@
INFINITY = float('inf')


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class SizeAlias(object):
is_alias = True

Expand All @@ -46,7 +45,7 @@ def add_to_sizes_dict(self, sizes):
ctx.update(size_to)


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class Size(object):

is_alias = False
Expand Down
10 changes: 7 additions & 3 deletions cropduster/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import PIL
import distutils.spawn
from distutils.version import LooseVersion
import six
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils import six


CROPDUSTER_MEDIA_ROOT = getattr(settings, 'CROPDUSTER_MEDIA_ROOT', settings.MEDIA_ROOT)
Expand Down Expand Up @@ -45,8 +45,12 @@ def get_jpeg_quality(width, height):
"CROPDUSTER_JPEG_QUALITY setting must be either a callable "
"or a numeric value, got type %s" % (type(CROPDUSTER_JPEG_QUALITY).__name__))

JPEG_SAVE_ICC_SUPPORTED = (LooseVersion(getattr(PIL, 'PILLOW_VERSION', '0'))
>= LooseVersion('2.2.1'))
try:
PILLOW_VERSION = getattr(PIL, '__version__', '0')
except AttributeError:
PILLOW_VERSION = getattr(PIL, 'PILLOW_VERSION', '0')

JPEG_SAVE_ICC_SUPPORTED = (LooseVersion(PILLOW_VERSION) >= LooseVersion('2.2.1'))

CROPDUSTER_GIFSICLE_PATH = getattr(settings, 'CROPDUSTER_GIFSICLE_PATH', None)

Expand Down
2 changes: 1 addition & 1 deletion cropduster/standalone/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import tempfile
from io import open

import six
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import default_storage
from django.utils.encoding import force_bytes
from django.utils import six

from cropduster.files import ImageFile
from cropduster.utils import json
Expand Down
10 changes: 5 additions & 5 deletions cropduster/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import six
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from cropduster.fields import ReverseForeignRelation
from cropduster.models import CropDusterField, Size
Expand Down Expand Up @@ -76,7 +76,7 @@ class TestMultipleFieldsInheritanceChild(TestMultipleFieldsInheritanceParent):
field_identifier="2")


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class TestReverseForeignRelA(models.Model):
slug = models.SlugField()
c = models.ForeignKey('TestReverseForeignRelC', on_delete=models.CASCADE)
Expand All @@ -90,7 +90,7 @@ def __str__(self):
return self.slug


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class TestReverseForeignRelB(models.Model):
slug = models.SlugField()
c = models.ForeignKey('TestReverseForeignRelC', on_delete=models.CASCADE)
Expand All @@ -99,7 +99,7 @@ def __str__(self):
return self.slug


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class TestReverseForeignRelC(models.Model):
slug = models.SlugField()
rel_a = ReverseForeignRelation(
Expand All @@ -110,7 +110,7 @@ def __str__(self):
return self.slug


@python_2_unicode_compatible
@six.python_2_unicode_compatible
class TestReverseForeignRelM2M(models.Model):
slug = models.SlugField()
m2m = models.ManyToManyField(TestReverseForeignRelC)
Expand Down
2 changes: 1 addition & 1 deletion cropduster/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import os
import PIL

from six.moves import range
from django.core.files.storage import default_storage
from django.test import TestCase
from django.contrib.contenttypes.models import ContentType
from django.utils.six.moves import range

from .helpers import CropdusterTestCaseMediaMixin
from .models import (
Expand Down
10 changes: 5 additions & 5 deletions cropduster/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
import math
from distutils.version import LooseVersion

import six
from six.moves import xrange

import PIL.Image
from PIL import ImageFile, JpegImagePlugin

from django.core.files.storage import default_storage
from django.utils import six
from django.utils.six.moves import xrange

from cropduster.settings import (
get_jpeg_quality, JPEG_SAVE_ICC_SUPPORTED, CROPDUSTER_GIFSICLE_PATH)
get_jpeg_quality, JPEG_SAVE_ICC_SUPPORTED, CROPDUSTER_GIFSICLE_PATH, PILLOW_VERSION)

from .gifsicle import GifsicleImage

Expand Down Expand Up @@ -178,8 +179,7 @@ def smart_resize(im, final_w, final_h):

# Pillow 2.7.0 greatly improved the bicubic resize algorithm, which makes
# our multiple-step resizing unnecessary
pillow_version = getattr(PIL, 'PILLOW_VERSION', None)
if pillow_version and LooseVersion(pillow_version) >= LooseVersion('2.7.0'):
if PILLOW_VERSION and LooseVersion(PILLOW_VERSION) >= LooseVersion('2.7.0'):
return im.resize((final_w, final_h), PIL.Image.BICUBIC)

# Attempt to resize the image 1/8, 2/8, such that it is at least 1.5x bigger
Expand Down
4 changes: 2 additions & 2 deletions cropduster/utils/jsonutils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from django.utils import six
from django.utils.six.moves import filter
import six
from six.moves import filter

from cropduster.resizing import Size

Expand Down
2 changes: 1 addition & 1 deletion cropduster/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os
import re

import six
from django.core.files.storage import default_storage, FileSystemStorage
from django.conf import settings
from django.db.models.fields.files import FileField
from django.utils import six


__all__ = ('get_upload_foldername')
Expand Down
2 changes: 1 addition & 1 deletion cropduster/utils/sizes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import division

from django.utils import six
import six

from . import jsonutils as json
from ..resizing import Size
Expand Down
5 changes: 3 additions & 2 deletions cropduster/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import shutil
import time

import six
from six.moves import filter, map, zip

import django
from django.conf import settings
from django.contrib.auth.decorators import login_required
Expand All @@ -45,8 +48,6 @@
from django.utils.decorators import method_decorator
from django.utils.encoding import force_text
from django.utils.functional import cached_property
from django.utils import six
from django.utils.six.moves import filter, map, zip
from django.views.decorators.csrf import csrf_exempt

import PIL.Image
Expand Down
3 changes: 1 addition & 2 deletions cropduster/views/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from functools import update_wrapper

from logging import getLogger

import six
from django import http
from django.utils.decorators import classonlymethod
from django.utils import six


logger = getLogger('django.request')
Expand Down
2 changes: 1 addition & 1 deletion cropduster/views/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import hashlib

import six
import PIL.Image

from django import forms
Expand All @@ -16,7 +17,6 @@
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from django.templatetags.static import static
from django.utils import six

from cropduster.models import Thumb
from cropduster.utils import (json, get_upload_foldername, get_min_size,
Expand Down
7 changes: 7 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class RunTests(selenosis.RunTests):
def __call__(self, *args, **kwargs):
warnings.simplefilter("error", Warning)
warnings.filterwarnings('ignore', message='.*?ckeditor')

# Introduced in Python 3.7
warnings.filterwarnings(
'ignore',
category=DeprecationWarning,
message="Using or importing the ABCs from 'collections' instead of from 'collections.abc'",
)
super(RunTests, self).__call__(*args, **kwargs)


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
license='BSD',
platforms='any',
install_requires=[
'six',
'Pillow',
'python-xmp-toolkit',
'django-generic-plus>=2.0.3',
Expand All @@ -37,7 +38,7 @@
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
])
Loading

0 comments on commit ce04202

Please sign in to comment.