From c0c89ca5264986cf4c1dcd8dc2e40d379cb7cfc6 Mon Sep 17 00:00:00 2001 From: Dalibor Pavlovic Date: Thu, 7 Apr 2022 15:59:33 +0200 Subject: [PATCH] Edit tests and setup for Django 3.2, Python 3.7 and above, Postgres 10 --- .travis.yml | 51 +++++++-------------------------------------- Dockerfile | 4 ++-- multigtfs/compat.py | 14 ++----------- requirements.txt | 3 +-- setup.py | 26 +++++------------------ tox.ini | 15 ++----------- 6 files changed, 20 insertions(+), 93 deletions(-) diff --git a/.travis.yml b/.travis.yml index b3fd0ba..76a4868 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: python -dist: trusty +dist: bionic sudo: false addons: - postgresql: 9.5 + postgresql: "10" apt: packages: - - postgresql-9.5-postgis-2.3 + - postgresql-10-postgis-2.4 install: pip install tox coveralls script: tox -e $TOX_ENV after_success: coveralls @@ -16,46 +16,11 @@ before_script: - psql -U postgres -d multigtfs -c "CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS postgis_topology;" matrix: include: - - env: TOX_ENV=py27-django18-postgis - python: "2.7" - - env: TOX_ENV=py34-django18-postgis - python: "3.4" - - env: TOX_ENV=py27-django19-postgis - python: "2.7" - - env: TOX_ENV=py35-django19-postgis - python: "3.5" - - env: TOX_ENV=py27-django110-postgis - python: "2.7" - - env: TOX_ENV=py35-django110-postgis - python: "3.5" - - env: TOX_ENV=py27-django111-postgis - python: "2.7" - - env: TOX_ENV=py36-django111-postgis - python: "3.6" - - env: TOX_ENV=py35-django20-postgis - python: "3.5" - - env: TOX_ENV=py36-django20-postgis - python: "3.6" - - env: TOX_ENV=py35-django21-postgis - python: "3.5" - - env: TOX_ENV=py36-django21-postgis - python: "3.6" - - env: TOX_ENV=py35-django22-postgis - python: "3.5" - - env: TOX_ENV=py37-django22-postgis + - env: TOX_ENV=py37-django-32-postgis python: "3.7" - sudo: required - dist: xenial - - env: TOX_ENV=py35-django-master-postgis - python: "3.5" - - env: TOX_ENV=py36-django-master-postgis - python: "3.6" - - env: TOX_ENV=py37-django-master-postgis - python: "3.7" - sudo: required - dist: xenial + - env: TOX_ENV=py38-django-32-postgis + python: "3.8" + - env: TOX_ENV=py39-django-32-postgis + python: "3.9" allow_failures: # Django master is allowed to fail - - env: TOX_ENV=py35-django-master-postgis - - env: TOX_ENV=py36-django-master-postgis - - env: TOX_ENV=py37-django-master-postgis diff --git a/Dockerfile b/Dockerfile index fbd50f5..fe3338c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM python:3.6 +FROM python:3.7-buster ENV PYTHONUNBUFFERED 1 RUN apt-get update RUN apt-get install -y binutils libproj-dev gdal-bin postgresql-client -RUN pip install "django>=2.2" "psycopg2" +RUN pip install "django>=2.2,<4.0" "psycopg2" RUN mkdir /code RUN mkdir /feeds diff --git a/multigtfs/compat.py b/multigtfs/compat.py index d7858c8..878eb4f 100644 --- a/multigtfs/compat.py +++ b/multigtfs/compat.py @@ -4,6 +4,7 @@ """ from codecs import BOM_UTF8 from distutils.version import LooseVersion +from io import TextIOWrapper from zipfile import ZipFile, ZIP_DEFLATED from django import get_version @@ -75,7 +76,6 @@ def opener_from_zipfile(zipfile): def opener(filename): inner_file = zipfile.open(filename) - from io import TextIOWrapper return TextIOWrapper(inner_file) return opener @@ -97,16 +97,6 @@ def write_text_rows(writer, rows): writer.writerow(new_row) -# The GeoQuerySet is deprecated in Django 1.8 -# https://docs.djangoproject.com/en/dev/releases/1.9/#django-contrib-gis -# The GeoManager is deprecated in Django 1.9 -# https://docs.djangoproject.com/en/dev/releases/1.9/#geomanager-and-geoqueryset-custom-methods -# They are removed in Django 2.0 -# https://docs.djangoproject.com/en/dev/releases/2.0/#features-removed-in-2-0 -if DJ_VERSION >= LooseVersion('2.0'): - from django.db.models import Manager, QuerySet -else: - from django.contrib.gis.db.models import GeoManager as Manager - from django.contrib.gis.db.models.query import GeoQuerySet as QuerySet +from django.db.models import Manager, QuerySet assert Manager assert QuerySet diff --git a/requirements.txt b/requirements.txt index d0809db..807ac90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -Django>=2.2 -jsonfield==3.1.0 +Django>=3.2,<4.0 diff --git a/setup.py b/setup.py index 970196d..c813356 100755 --- a/setup.py +++ b/setup.py @@ -58,13 +58,7 @@ def get_long_description(): return long_description -# Handle Py2/Py3 issue -if sys.version_info > (3, 0): - # In Py3, package data is dict w/ text key - package_data = {'multigtfs': ['tests/fixtures/*.zip']} -else: - # In Py2, package data is dict w/ binary string - package_data = {b'multigtfs': ['tests/fixtures/*.zip']} +package_data = {'multigtfs': ['tests/fixtures/*.zip']} setup( @@ -77,7 +71,7 @@ def get_long_description(): license='Apache License 2.0', url='https://github.com/tulsawebdevs/django-multi-gtfs', packages=find_packages(), - install_requires=['Django>=2.2', 'jsonfield>=0.9.20'], + install_requires=['Django>=3.2,<4.0'], keywords=['django', 'gtfs'], test_suite="run_tests", # Ignored, but makes pyroma happy cmdclass={'test': my_test}, @@ -86,24 +80,14 @@ def get_long_description(): "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 1.8", - "Framework :: Django :: 1.9", - "Framework :: Django :: 1.10", - "Framework :: Django :: 1.11", - "Framework :: Django :: 2.0", - "Framework :: Django :: 2.1", - "Framework :: Django :: 2.2", + "Framework :: Django :: 3.2", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", - "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", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Software Development :: Libraries :: Python Modules", ], include_package_data=True, diff --git a/tox.ini b/tox.ini index ec41456..e30cd69 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,6 @@ [tox] envlist = - py{27,34}-django18-{postgis,spatiallite} - py{27,34,35}-django{19,110}-{postgis,spatiallite} - py{27,34,35,36}-django111-{postgis,spatiallite} - py{35,36}-django20-{postgis,spatiallite} - py{35,36,37}-django{21,22,-master}-{postgis,spatiallite} + py{37,38,39}-django{32,-master}-{postgis,spatiallite} [flake8] exclude = .tox/*,.build/*,.dist/*,build/* @@ -14,17 +10,10 @@ passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH setenv = postgis: MULTIGTFS_TEST_POSTGIS = 1 deps= - django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 - django110: Django>=1.10,<1.11 - django111: Django>=1.11,<2.0 - django20: Django>=2.0,<2.1 - django21: Django>=2.1,<2.2 - django22: Django>=2.2,<3.0 + django32: Django>=3.2,<4.0 django-master: https://github.com/django/django/archive/master.tar.gz postgis: psycopg2 nose django-nose - jsonfield coveralls commands=coverage run --source multigtfs ./run_tests.py