From 65b5d456bdfc6319dd5e9887a8b7ab3d83ec5e93 Mon Sep 17 00:00:00 2001 From: Andreas Peldszus Date: Fri, 19 Jul 2024 23:23:35 +0200 Subject: [PATCH] Support python 3.10 to 3.12 * Enable building and testing for python 3.10 to 3.12. * The imp module is deprecated in 3.12. * The version is moved into a designated module that can be imported by setup.py without importing the whole module. * Make use of the extends syntax in gitlab-ci. * Restrict pytest < 8.2 because of issues with async tests. (https://github.com/pytest-dev/pytest/issues/12263) * Replace deprecated unittest assertEquals with assertEqual. --- .gitlab-ci.yml | 55 ++++++++++++++++++++++++++++++-------- .travis.yml | 9 +++---- CHANGELOG.rst | 15 +++++++++++ Makefile | 26 +++++++----------- requirements-test.txt | 2 +- setup.py | 16 ++++------- supercell/__init__.py | 6 +++-- supercell/version.py | 18 +++++++++++++ test/test_acceptparsing.py | 18 ++++++------- 9 files changed, 110 insertions(+), 55 deletions(-) create mode 100644 supercell/version.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 241212e..e541345 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip" -.test_template: &test_template +.test_template: stage: test cache: key: ${CI_JOB_NAME} @@ -23,12 +23,12 @@ variables: - cat pylint-report.txt coverage: '/^TOTAL.*\s+(\d+\%)$/' -.sonar_template: &sonar_template +.sonar_template: stage: sonar image: ciricihq/gitlab-sonar-scanner before_script: - export SONAR_ANALYSIS_MODE=publish - - projectVersion=$(awk -F\" '/^__version__ = / {print $2}' supercell/__init__.py) + - projectVersion=$(awk -F\" '/^__version__ = / {print $2}' supercell/version.py) - echo sonar.projectVersion=${projectVersion} >> sonar-project.properties - echo "sonar.projectKey=RTR:${projectKey}" >> sonar-project.properties - 'echo "sonar.projectName=Python :: ${projectKey}" >> sonar-project.properties' @@ -47,45 +47,78 @@ stages: - sonar test:36: + extends: .test_template image: python:3.6 - <<: *test_template test:37: + extends: .test_template image: python:3.7 - <<: *test_template test:38: + extends: .test_template image: python:3.8 - <<: *test_template test:39: + extends: .test_template image: python:3.9 - <<: *test_template + +test:310: + extends: .test_template + image: python:3.10 + +test:311: + extends: .test_template + image: python:3.11 + +test:312: + extends: .test_template + image: python:3.12 sonar:36: - <<: *sonar_template + extends: .sonar_template dependencies: - test:36 variables: projectKey: supercell-36 sonar:37: - <<: *sonar_template + extends: .sonar_template dependencies: - test:37 variables: projectKey: supercell-37 sonar:38: - <<: *sonar_template + extends: .sonar_template dependencies: - test:38 variables: projectKey: supercell-38 sonar:39: - <<: *sonar_template + extends: .sonar_template dependencies: - test:39 variables: projectKey: supercell-39 + +sonar:310: + extends: .sonar_template + dependencies: + - test:310 + variables: + projectKey: supercell-310 + +sonar:311: + extends: .sonar_template + dependencies: + - test:311 + variables: + projectKey: supercell-311 + +sonar:312: + extends: .sonar_template + dependencies: + - test:312 + variables: + projectKey: supercell-312 diff --git a/.travis.yml b/.travis.yml index 076de13..a71476b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,18 @@ language: python python: - - 2.7 - - 3.4 - 3.6 - 3.7 - 3.8 - 3.9 - - pypy - - pypy3 + - 3.10 + - 3.11 + - 3.12 # command to install dependencies install: - pip install -r requirements.txt - pip install -r requirements-test.txt - pip install coveralls - - python setup.py install + - pip install -e . script: - python travistest.py after_success: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2c72728..52e6578 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,18 @@ +Next version +------------------------- + +New Features +~~~~~~~~~~~~ + +* support of Python 3.10 to 3.12 + + +Development Changes +~~~~~~~~~~~~~~~~~~~ + +* removal left-over traces of support of Python version < 3.6. + + 0.12.0 - (September 25, 2023) ------------------------- diff --git a/Makefile b/Makefile index 6361981..e431ed0 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,27 @@ SRCDIR=supercell TEST?=test -VIRTUALENV=virtualenv - -#################################################### -# system python VIRTUALENV_DIR=${PWD}/env PIP=${VIRTUALENV_DIR}/bin/pip PYTHON=${VIRTUALENV_DIR}/bin/python -.PHONY: test -test: - ${VIRTUALENV_DIR}/bin/py.test -vvrw ${TEST} --cov ${SRCDIR} --cov-report=term:skip-covered --cov-report=xml:coverage.xml +.PHONY: all +all: virtualenv install .PHONY: virtualenv virtualenv: - if [ ! -e ${PIP} ]; then \ - ${VIRTUALENV} -p python ${VIRTUALENV_DIR}; \ - fi + if [ ! -e ${PIP} ]; then python3.6 -m venv ${VIRTUALENV_DIR}; fi ${PIP} install --upgrade pip .PHONY: install install: virtualenv - ${PIP} install -r requirements.txt; - ${PYTHON} setup.py develop; - ${PIP} install -r requirements-test.txt; + ${PIP} install -r requirements.txt + ${PIP} install -e . + ${PIP} install -r requirements-test.txt + +.PHONY: test +test: + ${VIRTUALENV_DIR}/bin/py.test -vvrw ${TEST} --cov ${SRCDIR} --cov-report=term:skip-covered --cov-report=xml:coverage.xml -#################################################### .PHONY: clean clean: -rm -f .DS_Store .coverage @@ -35,7 +31,5 @@ clean: .PHONY: dist-clean dist-clean: clean - -rm -rf ${VIRTUALENV_DIR3}; - rm -rf ${VIRTUALENV_DIR2}; rm -rf ${VIRTUALENV_DIR}; find . -depth -name '*.egg-info' -exec rm -rf {} \; diff --git a/requirements-test.txt b/requirements-test.txt index 7053581..e362184 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,4 @@ mock == 2.0.0 -pytest +pytest < 8.2 pytest-cov < 2.6.0 pylint diff --git a/setup.py b/setup.py index c811dec..b42462e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# vim: set fileencoding=utf-8 : # # Copyright (c) 2012 Daniel Truemper # @@ -15,14 +14,11 @@ # limitations under the License. # # -from imp import load_source import os from setuptools import setup import sys - -init = load_source('init', os.path.join('supercell', '__init__.py')) -PY2 = sys.version_info[0] == 2 +from supercell.version import __version__ tests_require = [ @@ -35,8 +31,6 @@ extras_require = {} extras_require['test'] = tests_require extras_require['futures'] = '' -if PY2: - extras_require['futures'] = 'futures == 2.2.0' def readme(): @@ -46,7 +40,7 @@ def readme(): setup( name='supercell', - version=init.__version__, + version=__version__, author='Daniel Truemper', author_email='truemped@gmail.com', @@ -69,12 +63,12 @@ def readme(): 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: Implementation :: PyPy', ] ) diff --git a/supercell/__init__.py b/supercell/__init__.py index 89a5472..696941c 100644 --- a/supercell/__init__.py +++ b/supercell/__init__.py @@ -1,4 +1,3 @@ -# vim: set fileencoding=utf-8 : # # Copyright (c) 2013 Daniel Truemper # @@ -15,4 +14,7 @@ # limitations under the License. # # -__version__ = "0.12.0" + +from supercell.version import __version__ + +__all__ = ['__version__'] diff --git a/supercell/version.py b/supercell/version.py new file mode 100644 index 0000000..4581fc7 --- /dev/null +++ b/supercell/version.py @@ -0,0 +1,18 @@ +# +# Copyright (c) 2013 Daniel Truemper +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +__version__ = "0.12.0" diff --git a/test/test_acceptparsing.py b/test/test_acceptparsing.py index c5aef9a..e958515 100644 --- a/test/test_acceptparsing.py +++ b/test/test_acceptparsing.py @@ -16,46 +16,46 @@ def test_parse_accept_header_browser(self): ('application/json', {}, 1.0), ('application/xml', {}, 0.9), ('*/*', {}, 0.8)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_smart_client(self): accept = "application/vnd.ficture.lightt-v1.1+json" should = [('application/json', {'version': 1.1, 'vendor': 'ficture.lightt'}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_smart_client_without_version(self): accept = "application/vnd.ficture.lightt+json" should = [('application/json', {'vendor': 'ficture.lightt'}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_dumbish_client(self): accept = "application/vnd.ficture.lightt-v1.0" should = [('application/vnd.ficture.lightt-v1.0', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_also_dumb_client(self): accept = "application/vnd.ficture.lightt" should = [('application/vnd.ficture.lightt', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_dumb_client(self): accept = "application/json" should = [('application/json', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_really_dumb_client(self): accept = "" should = [('*/*', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_iesix_bad_accept_header(self): accept = 'text/*,image/*;application/*;*/*;' should = [('*/*', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should) def test_parse_accept_header_wildcard(self): accept = '*/*' should = [('*/*', {}, 1.0)] - self.assertEquals(parse_accept_header(accept), should) + self.assertEqual(parse_accept_header(accept), should)