Skip to content

Commit

Permalink
Support python 3.10 to 3.12
Browse files Browse the repository at this point in the history
* 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.
  (pytest-dev/pytest#12263)
* Replace deprecated unittest assertEquals with assertEqual.
  • Loading branch information
peldszus committed Jul 19, 2024
1 parent 119e1e9 commit 65b5d45
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 55 deletions.
55 changes: 44 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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'
Expand All @@ -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
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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)
-------------------------

Expand Down
26 changes: 10 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {} \;
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mock == 2.0.0
pytest
pytest < 8.2
pytest-cov < 2.6.0
pylint
16 changes: 5 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# vim: set fileencoding=utf-8 :
#
# Copyright (c) 2012 Daniel Truemper <truemped at googlemail.com>
#
Expand All @@ -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 = [
Expand All @@ -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():
Expand All @@ -46,7 +40,7 @@ def readme():

setup(
name='supercell',
version=init.__version__,
version=__version__,

author='Daniel Truemper',
author_email='[email protected]',
Expand All @@ -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',
]
)
6 changes: 4 additions & 2 deletions supercell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# vim: set fileencoding=utf-8 :
#
# Copyright (c) 2013 Daniel Truemper <truemped at googlemail.com>
#
Expand All @@ -15,4 +14,7 @@
# limitations under the License.
#
#
__version__ = "0.12.0"

from supercell.version import __version__

__all__ = ['__version__']
18 changes: 18 additions & 0 deletions supercell/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2013 Daniel Truemper <truemped at googlemail.com>
#
# 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"
18 changes: 9 additions & 9 deletions test/test_acceptparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 65b5d45

Please sign in to comment.