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:
parent
22a05b2039
commit
2636965f38
@ -30,7 +30,6 @@
|
|||||||
templates:
|
templates:
|
||||||
- check-requirements
|
- check-requirements
|
||||||
- lib-forward-testing-python3
|
- lib-forward-testing-python3
|
||||||
- openstack-python-jobs
|
|
||||||
- openstack-python3-zed-jobs
|
- openstack-python3-zed-jobs
|
||||||
- publish-openstack-docs-pti
|
- publish-openstack-docs-pti
|
||||||
- release-notes-jobs-python3
|
- release-notes-jobs-python3
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
futures>=3.0.0;python_version=='2.7' # BSD
|
|
||||||
requests>=1.1.0
|
requests>=1.1.0
|
||||||
six>=1.9.0
|
six>=1.9.0
|
||||||
|
@ -9,7 +9,7 @@ function usage {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "This script is deprecated and currently retained for compatibility."
|
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 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".'
|
echo 'the pep8 tests with "tox -e pep8".'
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ if [ $just_pep8 -eq 1 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
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
|
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||||
exit ${PIPESTATUS[0]}
|
exit ${PIPESTATUS[0]}
|
||||||
fi
|
fi
|
||||||
|
@ -3,9 +3,11 @@ name = python-swiftclient
|
|||||||
summary = OpenStack Object Storage API Client Library
|
summary = OpenStack Object Storage API Client Library
|
||||||
description_file =
|
description_file =
|
||||||
README.rst
|
README.rst
|
||||||
|
license = Apache License, Version 2.0
|
||||||
author = OpenStack
|
author = OpenStack
|
||||||
author_email = openstack-discuss@lists.openstack.org
|
author_email = openstack-discuss@lists.openstack.org
|
||||||
home_page = https://docs.openstack.org/python-swiftclient/latest/
|
home_page = https://docs.openstack.org/python-swiftclient/latest/
|
||||||
|
python_requires = >=3.6
|
||||||
classifier =
|
classifier =
|
||||||
Environment :: OpenStack
|
Environment :: OpenStack
|
||||||
Intended Audience :: Information Technology
|
Intended Audience :: Information Technology
|
||||||
@ -14,13 +16,12 @@ classifier =
|
|||||||
Operating System :: POSIX :: Linux
|
Operating System :: POSIX :: Linux
|
||||||
Operating System :: Microsoft :: Windows
|
Operating System :: Microsoft :: Windows
|
||||||
Programming Language :: Python
|
Programming Language :: Python
|
||||||
Programming Language :: Python :: 2
|
|
||||||
Programming Language :: Python :: 2.7
|
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3.6
|
Programming Language :: Python :: 3.6
|
||||||
Programming Language :: Python :: 3.7
|
Programming Language :: Python :: 3.7
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
|
Programming Language :: Python :: 3 :: Only
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
@ -41,9 +42,6 @@ console_scripts =
|
|||||||
keystoneauth1.plugin =
|
keystoneauth1.plugin =
|
||||||
v1password = swiftclient.authv1:PasswordLoader
|
v1password = swiftclient.authv1:PasswordLoader
|
||||||
|
|
||||||
[bdist_wheel]
|
|
||||||
universal = 1
|
|
||||||
|
|
||||||
[pbr]
|
[pbr]
|
||||||
skip_authors = True
|
skip_authors = True
|
||||||
skip_changelog = True
|
skip_changelog = True
|
||||||
|
9
setup.py
9
setup.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -14,12 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
|
import setuptools
|
||||||
import setuptools, sys
|
|
||||||
|
|
||||||
if sys.version_info < (2, 7):
|
|
||||||
sys.exit('Sorry, Python < 2.7 is not supported for'
|
|
||||||
' python-swiftclient>=3.0')
|
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
setup_requires=['pbr'],
|
setup_requires=['pbr'],
|
||||||
|
@ -48,25 +48,11 @@ USER_METADATA_TYPE = tuple('x-%s-meta-' % type_ for type_ in
|
|||||||
URI_PATTERN_INFO = re.compile(r'/info')
|
URI_PATTERN_INFO = re.compile(r'/info')
|
||||||
URI_PATTERN_VERSION = re.compile(r'\/v\d+\.?\d*(\/.*)?')
|
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
|
ksexceptions = ksclient_v2 = ksclient_v3 = ksa_v3 = None
|
||||||
try:
|
try:
|
||||||
from keystoneclient import exceptions as ksexceptions
|
from keystoneclient import exceptions as ksexceptions
|
||||||
# prevent keystoneclient warning us that it has no log handlers
|
# 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
|
from keystoneclient.v2_0 import client as ksclient_v2
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
@ -93,7 +79,7 @@ if StrictVersion(requests.__version__) < StrictVersion('2.0.0') \
|
|||||||
requests.models.PreparedRequest.prepare_headers = prepare_unicode_headers
|
requests.models.PreparedRequest.prepare_headers = prepare_unicode_headers
|
||||||
|
|
||||||
logger = logging.getLogger("swiftclient")
|
logger = logging.getLogger("swiftclient")
|
||||||
logger.addHandler(NullHandler())
|
logger.addHandler(logging.NullHandler())
|
||||||
|
|
||||||
#: Default behaviour is to redact header values known to contain secrets,
|
#: 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
|
#: such as ``X-Auth-Key`` and ``X-Auth-Token``. Up to the first 16 chars
|
||||||
|
@ -1976,34 +1976,8 @@ class TestHTTPConnection(MockHttpTest):
|
|||||||
self.assertFalse(resp.read())
|
self.assertFalse(resp.read())
|
||||||
self.assertTrue(resp.closed)
|
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):
|
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 = c.http_connection(u'http://www.test.com/')
|
||||||
conn.resp = MockHttpResponse(
|
conn.resp = MockHttpResponse(
|
||||||
|
16
tox.ini
16
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27,py3,pep8
|
envlist = py3,pep8
|
||||||
minversion = 3.18.0
|
minversion = 3.18.0
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
@ -21,16 +21,13 @@ allowlist_externals = sh
|
|||||||
passenv = SWIFT_* *_proxy
|
passenv = SWIFT_* *_proxy
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
|
||||||
commands =
|
commands =
|
||||||
python -m flake8 swiftclient test
|
python -m flake8 swiftclient test
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
basepython = python3
|
|
||||||
setenv =
|
setenv =
|
||||||
PYTHON=coverage run --source swiftclient --parallel-mode
|
PYTHON=coverage run --source swiftclient --parallel-mode
|
||||||
commands =
|
commands =
|
||||||
@ -41,7 +38,6 @@ commands =
|
|||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
[testenv:func]
|
[testenv:func]
|
||||||
basepython = python3
|
|
||||||
setenv =
|
setenv =
|
||||||
OS_TEST_PATH=test.functional
|
OS_TEST_PATH=test.functional
|
||||||
PYTHON=coverage run --source swiftclient --parallel-mode
|
PYTHON=coverage run --source swiftclient --parallel-mode
|
||||||
@ -56,14 +52,7 @@ commands =
|
|||||||
coverage report -m
|
coverage report -m
|
||||||
rm -f .coverage
|
rm -f .coverage
|
||||||
|
|
||||||
[testenv:py2func]
|
|
||||||
basepython=python2
|
|
||||||
setenv = {[testenv:func]setenv}
|
|
||||||
allowlist_externals = {[testenv:func]allowlist_externals}
|
|
||||||
commands = {[testenv:func]commands}
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python3
|
|
||||||
usedevelop = False
|
usedevelop = False
|
||||||
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
@ -88,7 +77,6 @@ show-source = True
|
|||||||
exclude = .venv,.tox,dist,doc,*egg
|
exclude = .venv,.tox,dist,doc,*egg
|
||||||
|
|
||||||
[testenv:bindep]
|
[testenv:bindep]
|
||||||
basepython = python3
|
|
||||||
# Do not install any requirements. We want this to be fast and work even if
|
# 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
|
# system dependencies are missing, since it's used to tell you what system
|
||||||
# dependencies are missing! This also means that bindep must be installed
|
# dependencies are missing! This also means that bindep must be installed
|
||||||
@ -98,14 +86,12 @@ deps = bindep
|
|||||||
commands = bindep test
|
commands = bindep test
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
basepython = python3
|
|
||||||
usedevelop = False
|
usedevelop = False
|
||||||
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||||
|
|
||||||
[testenv:pdf-docs]
|
[testenv:pdf-docs]
|
||||||
basepython = python3
|
|
||||||
deps = {[testenv:docs]deps}
|
deps = {[testenv:docs]deps}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
make
|
make
|
||||||
|
Loading…
Reference in New Issue
Block a user