Skip to content

Commit

Permalink
Merge pull request #150 from PoByBolek/distutils-deprecation-warning
Browse files Browse the repository at this point in the history
Prevent deprecation warnings for distutils StrictVersion when running with setuptools or Python >= 3.10
  • Loading branch information
paulocheque committed Aug 2, 2022
2 parents d51d8e5 + 0c1f505 commit 22518c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 2 additions & 3 deletions django_dynamic_fixture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
__version__ = '3.1.2'


if not django_greater_than('1.10'):
warnings.warn("DDF supports oficially only Django 1.11 or higher.", DeprecationWarning)
if not django_greater_than(1, 10):
warnings.warn("DDF officially supports only Django 1.11 or higher.", DeprecationWarning)


LOOKUP_SEP = '__'
Expand Down Expand Up @@ -213,4 +213,3 @@ def teach(model: typing.Type[INSTANCE_TYPE], ddf_lesson=None, **kwargs):
exec(hack_to_avoid_py2_syntax_errors)
except (ImportError, SyntaxError) as e:
pass

9 changes: 2 additions & 7 deletions django_dynamic_fixture/django_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"""
Module to wrap dirty stuff of django core.
"""
import re
from distutils.version import StrictVersion

import django
from django.apps import apps
from django.db import models # noqa
Expand All @@ -18,11 +15,9 @@
from django.core.exceptions import FieldDoesNotExist


def django_greater_than(major, minor=0):
return django.VERSION[:2] > (major, minor)

def django_greater_than(version):
# Avoid StrictVersion errors with versions like 1.8c1
DJANGO_VERSION = re.match(r"\d\.\d\d?", django.get_version()).group(0)
return StrictVersion(DJANGO_VERSION) >= StrictVersion(version)

# Apps
def get_apps(application_labels=[], exclude_application_labels=[]):
Expand Down

0 comments on commit 22518c3

Please sign in to comment.