Drop support for Python 2

There's a lot of cleanup possible, but this is a start.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ia1176b7fd5434d52070d482a37abfbb98800cdb3
This commit is contained in:
Stephen Finucane 2022-02-17 11:21:40 +00:00 committed by Tim Burke
parent 22a05b2039
commit 2636965f38
8 changed files with 12 additions and 74 deletions

View File

@ -30,7 +30,6 @@
templates:
- check-requirements
- lib-forward-testing-python3
- openstack-python-jobs
- openstack-python3-zed-jobs
- publish-openstack-docs-pti
- release-notes-jobs-python3

View File

@ -1,3 +1,3 @@
futures>=3.0.0;python_version=='2.7' # BSD
requests>=1.1.0
six>=1.9.0

View File

@ -9,7 +9,7 @@ function usage {
echo ""
echo "This script is deprecated and currently retained for compatibility."
echo 'You can run the full test suite for multiple environments by running "tox".'
echo 'You can run tests for only python 2.7 by running "tox -e py27", or run only'
echo 'You can run tests for only python 3.9 by running "tox -e py39", or run only'
echo 'the pep8 tests with "tox -e pep8".'
exit
}
@ -39,7 +39,7 @@ if [ $just_pep8 -eq 1 ]; then
exit
fi
tox -e py27 $toxargs 2>&1 | tee run_tests.err.log || exit
tox -e py39 $toxargs 2>&1 | tee run_tests.err.log || exit
if [ ${PIPESTATUS[0]} -ne 0 ]; then
exit ${PIPESTATUS[0]}
fi

View File

@ -3,9 +3,11 @@ name = python-swiftclient
summary = OpenStack Object Storage API Client Library
description_file =
README.rst
license = Apache License, Version 2.0
author = OpenStack
author_email = openstack-discuss@lists.openstack.org
home_page = https://docs.openstack.org/python-swiftclient/latest/
python_requires = >=3.6
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
@ -14,13 +16,12 @@ classifier =
Operating System :: POSIX :: Linux
Operating System :: Microsoft :: Windows
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3 :: Only
[files]
packages =
@ -41,9 +42,6 @@ console_scripts =
keystoneauth1.plugin =
v1password = swiftclient.authv1:PasswordLoader
[bdist_wheel]
universal = 1
[pbr]
skip_authors = True
skip_changelog = True

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -14,12 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools, sys
if sys.version_info < (2, 7):
sys.exit('Sorry, Python < 2.7 is not supported for'
' python-swiftclient>=3.0')
import setuptools
setuptools.setup(
setup_requires=['pbr'],

View File

@ -48,25 +48,11 @@ USER_METADATA_TYPE = tuple('x-%s-meta-' % type_ for type_ in
URI_PATTERN_INFO = re.compile(r'/info')
URI_PATTERN_VERSION = re.compile(r'\/v\d+\.?\d*(\/.*)?')
try:
from logging import NullHandler
except ImportError:
# Added in Python 2.7
class NullHandler(logging.Handler):
def handle(self, record):
pass
def emit(self, record):
pass
def createLock(self):
self.lock = None
ksexceptions = ksclient_v2 = ksclient_v3 = ksa_v3 = None
try:
from keystoneclient import exceptions as ksexceptions
# prevent keystoneclient warning us that it has no log handlers
logging.getLogger('keystoneclient').addHandler(NullHandler())
logging.getLogger('keystoneclient').addHandler(logging.NullHandler())
from keystoneclient.v2_0 import client as ksclient_v2
except ImportError:
pass
@ -93,7 +79,7 @@ if StrictVersion(requests.__version__) < StrictVersion('2.0.0') \
requests.models.PreparedRequest.prepare_headers = prepare_unicode_headers
logger = logging.getLogger("swiftclient")
logger.addHandler(NullHandler())
logger.addHandler(logging.NullHandler())
#: Default behaviour is to redact header values known to contain secrets,
#: such as ``X-Auth-Key`` and ``X-Auth-Token``. Up to the first 16 chars

View File

@ -1976,34 +1976,8 @@ class TestHTTPConnection(MockHttpTest):
self.assertFalse(resp.read())
self.assertTrue(resp.closed)
@unittest.skipIf(six.PY3, 'python2 specific test')
def test_response_python2_headers(self):
'''Test utf-8 headers in Python 2.
'''
_, conn = c.http_connection(u'http://www.test.com/')
conn.resp = MockHttpResponse(
status=200,
headers={
'\xd8\xaa-unicode': '\xd8\xaa-value',
'empty-header': ''
}
)
resp = conn.getresponse()
self.assertEqual(
'\xd8\xaa-value', resp.getheader('\xd8\xaa-unicode'))
self.assertEqual(
'\xd8\xaa-value', resp.getheader('\xd8\xaa-UNICODE'))
self.assertEqual('', resp.getheader('empty-header'))
self.assertEqual(
dict([('\xd8\xaa-unicode', '\xd8\xaa-value'),
('empty-header', ''),
('etag', '"%s"' % EMPTY_ETAG)]),
dict(resp.getheaders()))
@unittest.skipIf(six.PY2, 'python3 specific test')
def test_response_python3_headers(self):
'''Test latin1-encoded headers in Python 3.
'''Test latin1-encoded headers.
'''
_, conn = c.http_connection(u'http://www.test.com/')
conn.resp = MockHttpResponse(

16
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py27,py3,pep8
envlist = py3,pep8
minversion = 3.18.0
skipsdist = True
@ -21,16 +21,13 @@ allowlist_externals = sh
passenv = SWIFT_* *_proxy
[testenv:pep8]
basepython = python3
commands =
python -m flake8 swiftclient test
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:cover]
basepython = python3
setenv =
PYTHON=coverage run --source swiftclient --parallel-mode
commands =
@ -41,7 +38,6 @@ commands =
coverage report
[testenv:func]
basepython = python3
setenv =
OS_TEST_PATH=test.functional
PYTHON=coverage run --source swiftclient --parallel-mode
@ -56,14 +52,7 @@ commands =
coverage report -m
rm -f .coverage
[testenv:py2func]
basepython=python2
setenv = {[testenv:func]setenv}
allowlist_externals = {[testenv:func]allowlist_externals}
commands = {[testenv:func]commands}
[testenv:docs]
basepython = python3
usedevelop = False
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
@ -88,7 +77,6 @@ show-source = True
exclude = .venv,.tox,dist,doc,*egg
[testenv:bindep]
basepython = python3
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
@ -98,14 +86,12 @@ deps = bindep
commands = bindep test
[testenv:releasenotes]
basepython = python3
usedevelop = False
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:pdf-docs]
basepython = python3
deps = {[testenv:docs]deps}
allowlist_externals =
make