diff --git a/.zuul.yaml b/.zuul.yaml index 92889dcd..d38f37fa 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/requirements.txt b/requirements.txt index 4757239b..b7c92400 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -futures>=3.0.0;python_version=='2.7' # BSD + requests>=1.1.0 six>=1.9.0 diff --git a/run_tests.sh b/run_tests.sh index 6991cd1d..d1fc50ad 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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 diff --git a/setup.cfg b/setup.cfg index c780c388..e429b12f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 16a18f6e..22cfdce8 100644 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/swiftclient/client.py b/swiftclient/client.py index 544247a6..cc5478a8 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -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 diff --git a/test/unit/test_swiftclient.py b/test/unit/test_swiftclient.py index ea5f502f..f6dc258f 100644 --- a/test/unit/test_swiftclient.py +++ b/test/unit/test_swiftclient.py @@ -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( diff --git a/tox.ini b/tox.ini index fbc58c78..e1e679d2 100644 --- a/tox.ini +++ b/tox.ini @@ -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