Skip to content

Commit a1020d6

Browse files
authored
Merge pull request #5031 from djmitche/issue4614
Drop support for Python-2.7 in the client.
2 parents 492dcab + ea74d18 commit a1020d6

File tree

17 files changed

+49
-103
lines changed

17 files changed

+49
-103
lines changed

changelog/issue-4614.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
audience: developers
2+
level: minor
3+
reference: issue 4614
4+
---
5+
This version drops support for Python-2.7 in the Python client. Python-2.7's support window ended over one year ago.

clients/client-py/README.md

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/client-py/release.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ python3 -mvenv .release/py3
3131
# Work around https://bitbucket.org/pypa/wheel/issues/147/bdist_wheel-should-start-by-cleaning-up
3232
rm -rf build/
3333

34-
virtualenv --python=python2 .release/py2
35-
.release/py2/bin/pip install -U setuptools wheel
36-
.release/py2/bin/python setup.py bdist_wheel
37-
3834
ls -al dist
3935

4036
# Publish to PyPI using Twine, as recommended by:

clients/client-py/setup.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'pytest',
1111
'pytest-cov',
1212
'pytest-mock',
13-
'pytest-asyncio; python_version>="3.6"',
13+
'pytest-asyncio',
1414
'httmock',
1515
'mock',
1616
'setuptools-lint',
@@ -20,9 +20,8 @@
2020
'tox',
2121
'coverage',
2222
'python-dateutil',
23-
'subprocess32; python_version=="2.7"',
24-
'aiofiles; python_version>="3.6"',
25-
'httptest; python_version>="3.6"',
23+
'aiofiles',
24+
'httptest',
2625
]
2726

2827
# requests has a policy of not breaking apis between major versions
@@ -32,11 +31,8 @@
3231
'mohawk>=0.3.4',
3332
'slugid>=2',
3433
'taskcluster-urls>=12.1.0',
35-
'six>=1.10.0',
36-
37-
# python-3 only
38-
'aiohttp>=3.7.4; python_version>="3.6"',
39-
'async_timeout>=2.0.0; python_version>="3.6"',
34+
'aiohttp>=3.7.4',
35+
'async_timeout>=2.0.0',
4036
]
4137

4238
# from http://testrun.org/tox/latest/example/basic.html
@@ -65,12 +61,8 @@ def run_tests(self):
6561
if sys.version_info[0] == 3 and sys.version_info[:2] < (3, 5):
6662
raise Exception('This library does not support Python 3 versions below 3.5')
6763

68-
if sys.version_info.major == 2:
69-
with open('README.md') as f:
70-
long_description = f.read()
71-
else:
72-
with open('README.md', encoding='utf8') as f:
73-
long_description = f.read()
64+
with open('README.md', encoding='utf8') as f:
65+
long_description = f.read()
7466

7567
if __name__ == '__main__':
7668
setup(
@@ -96,8 +88,10 @@ def run_tests(self):
9688
},
9789
cmdclass={'test': Tox},
9890
zip_safe=False,
99-
classifiers=['Programming Language :: Python :: 2.7',
100-
'Programming Language :: Python :: 3.5',
101-
'Programming Language :: Python :: 3.6',
102-
'Programming Language :: Python :: 3.7'],
91+
classifiers=[
92+
'Programming Language :: Python :: 3.6',
93+
'Programming Language :: Python :: 3.7',
94+
'Programming Language :: Python :: 3.8',
95+
'Programming Language :: Python :: 3.9',
96+
],
10397
)

clients/client-py/taskcluster/aio/asyncclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import os
66
import logging
7-
from six.moves import urllib
7+
import urllib
88

99
import mohawk
1010
import mohawk.bewit

clients/client-py/taskcluster/aio/asyncutils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import functools
77
import logging
88
import os
9-
import six
109

1110
import taskcluster.utils as utils
1211
import taskcluster.exceptions as exceptions
@@ -101,7 +100,7 @@ async def makeSingleHttpRequest(method, url, payload, headers, session=None):
101100
log.debug('Received HTTP Status: %s' % resp.status)
102101
log.debug('Received HTTP Headers: %s' % str(resp.headers))
103102
log.debug('Received HTTP Payload: %s (limit 1024 char)' %
104-
six.text_type(response_text)[:1024])
103+
str(response_text)[:1024])
105104
return resp
106105
finally:
107106
if implicit:

clients/client-py/taskcluster/aio/download.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
This module provides several pre-defined writers and writer factories for
1515
common cases.
1616
"""
17-
import six
18-
19-
if six.PY2:
20-
raise ImportError("download is only supported in Python 3")
21-
2217
import aiohttp
2318
import contextlib
2419

clients/client-py/taskcluster/aio/upload.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
This module provides several pre-defined readers and reader factories for
1616
common cases.
1717
"""
18-
import six
19-
20-
if six.PY2:
21-
raise ImportError("upload is only supported in Python 3")
22-
2318
import base64
2419
import hashlib
2520

clients/client-py/taskcluster/client.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
import calendar
1212
import requests
1313
import time
14-
import six
1514
import warnings
16-
from six.moves import urllib
15+
import urllib
1716

1817
import mohawk
1918
import mohawk.bewit
@@ -66,7 +65,7 @@ def __init__(self, options=None, session=None):
6665
if credentials:
6766
for x in ('accessToken', 'clientId', 'certificate'):
6867
value = credentials.get(x)
69-
if value and not isinstance(value, six.binary_type):
68+
if value and not isinstance(value, bytes):
7069
try:
7170
credentials[x] = credentials[x].encode('ascii')
7271
except Exception:
@@ -98,9 +97,9 @@ def makeHawkExt(self):
9897
ext = {}
9998
cert = c.get('certificate')
10099
if cert:
101-
if six.PY3 and isinstance(cert, six.binary_type):
100+
if isinstance(cert, bytes):
102101
cert = cert.decode()
103-
if isinstance(cert, six.string_types):
102+
if isinstance(cert, str):
104103
cert = json.loads(cert)
105104
ext['certificate'] = cert
106105

@@ -130,7 +129,7 @@ def _makeTopicExchange(self, entry, *args, **kwargs):
130129
}
131130

132131
# If we are passed in a string, we can short-circuit this function
133-
if isinstance(routingKeyPattern, six.string_types):
132+
if isinstance(routingKeyPattern, str):
134133
log.debug('Passing through string for topic exchange key')
135134
data['routingKeyPattern'] = routingKeyPattern
136135
return data
@@ -355,12 +354,12 @@ def _processArgs(self, entry, *_args, **_kwargs):
355354
# These all need to be rendered down to a string, let's just check that
356355
# they are up front and fail fast
357356
for arg in args:
358-
if not isinstance(arg, six.string_types) and not isinstance(arg, int):
357+
if not isinstance(arg, str) and not isinstance(arg, int):
359358
raise exceptions.TaskclusterFailure(
360359
'Positional arg "%s" to %s is not a string or int' % (arg, entry['name']))
361360

362-
for name, arg in six.iteritems(kwApiArgs):
363-
if not isinstance(arg, six.string_types) and not isinstance(arg, int):
361+
for name, arg in kwApiArgs.items():
362+
if not isinstance(arg, str) and not isinstance(arg, int):
364363
raise exceptions.TaskclusterFailure(
365364
'KW arg "%s: %s" to %s is not a string or int' % (name, arg, entry['name']))
366365

@@ -419,7 +418,7 @@ def _subArgsInRoute(self, entry, args):
419418

420419
route = entry['route']
421420

422-
for arg, val in six.iteritems(args):
421+
for arg, val in args.items():
423422
toReplace = "<%s>" % arg
424423
if toReplace not in route:
425424
raise exceptions.TaskclusterFailure(
@@ -650,7 +649,7 @@ def createTemporaryCredentials(clientId, accessToken, start, expiry, scopes, nam
650649
"""
651650

652651
for scope in scopes:
653-
if not isinstance(scope, six.string_types):
652+
if not isinstance(scope, str):
654653
raise exceptions.TaskclusterFailure('Scope must be string')
655654

656655
# Credentials can only be valid for 31 days. I hope that
@@ -687,7 +686,7 @@ def createTemporaryCredentials(clientId, accessToken, start, expiry, scopes, nam
687686
] + scopes)
688687
sigStr = '\n'.join(sig).encode()
689688

690-
if isinstance(accessToken, six.text_type):
689+
if isinstance(accessToken, str):
691690
accessToken = accessToken.encode()
692691
sig = hmac.new(accessToken, sigStr, hashlib.sha256).digest()
693692

clients/client-py/taskcluster/download.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
common cases.
1313
"""
1414
import functools
15-
import six
16-
17-
if six.PY2:
18-
raise ImportError("download is only supported in Python 3")
1915

2016
from .aio import download as aio_download
2117
from .aio.asyncutils import ensureCoro, runAsync

0 commit comments

Comments
 (0)