diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f932a5..fe8efbc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 5 @@ -14,7 +14,17 @@ jobs: steps: - uses: actions/checkout@v2 + # Special handling for Python 2.7 + - name: Set up Python 2.7 and pip (+ install dependencies) + if: matrix.python-version == '2.7' + run: | + sudo apt-get update + sudo apt-get install -y python2.7 python-pip + python2.7 -m pip install --upgrade "pip<21.0" "setuptools<45" + python2.7 -m pip install tox==3.24.4 tox-gh-actions + - name: Set up Python ${{ matrix.python-version }} + if: matrix.python-version != '2.7' uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -33,7 +43,8 @@ jobs: restore-keys: | ${{ matrix.python-version }}-v1- - - name: Install dependencies + - name: Install dependencies for Python 3.x + if: matrix.python-version != '2.7' run: | python -m pip install --upgrade pip setuptools python -m pip install --upgrade tox tox-gh-actions diff --git a/authority/admin.py b/authority/admin.py index da06ec1..0e046bf 100644 --- a/authority/admin.py +++ b/authority/admin.py @@ -12,15 +12,17 @@ from django.core.exceptions import PermissionDenied from sys import version_info as python_version -if django_version[0] >= 4: +if django_version >= (4, 0): from django.utils.encoding import force_str as force_text # Django 4.x -elif django_version[0] >= 2: +elif django_version >= (2, 0): from django.utils.encoding import force_text # Django 2.x and 3.x -else: +elif django_version >= (1, 11): if python_version[0] < 3: - from django.utils.encoding import force_unicode as force_text # Django 1.x with Python 2.x + from django.utils.encoding import force_unicode as force_text # Django 1.x with Python 2.7 else: - raise ImportError("Unsupported Django version or Python version") + from django.utils.encoding import force_text +else: + raise ImportError("Unsupported Django version or Python version") from authority.models import Permission from authority.widgets import GenericForeignKeyRawIdWidget diff --git a/tox.ini b/tox.ini index b317667..4246b1f 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ commands = coverage xml deps = coverage + setuptools dj111: Django>=1.11,<2.0 dj22: Django>=2.2,<2.3 dj30: Django>=3.0,<3.1