Skip to content
Myr

Farewell, sweet Concorde!

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Formally removing any remaining vestiges of Python 2 from Requests. We'll also leave behind Python 3.6 while we're at it.

authored by Nate Prewitt · committed by GitHub · parent 79f6027 · Browse files · 19 files+139 added−178 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

19 files+139 added−178 removed

  • tests:+46 added−52 removed
  • other:+93 added−126 removed

19 files+139 added−178 removed

modified:.github/workflows/run-tests.yml+2 added-5 removed
modified:docs/community/faq.rst+6 added-9 removed
53 unmodified lines
5455Python 3 Support?56-----------------5758Yes! Requests officially supports Python 2.7 & 3.6+ and PyPy.58Yes! Requests officially supports Python 3.7+ and PyPy.5960Python 2 Support?61-----------------6263Yes! We understand that we have a large user base with varying needs. Through64**at least** Requests 2.27.x, we will be providing continued support for Python652.7. However, this support is likely to end some time in 2022.63No! As of Requests 2.28.0, Requests no longer supports Python 2.7. Users who64have been unable to migrate should pin to `requests<2.28`. Full information65can be found in `psf/requests#6023 <https://github.com/psf/requests/issues/6023>`_.6667It is *highly* recommended users migrate to Python 3.7+ now since Python67It is *highly* recommended users migrate to Python 3.8+ now since Python682.7 is no longer receiving bug fixes or security updates as of January 1, 2020.6970What are "hostname doesn't match" errors?71-----------------------------------------
10 unmodified lines
82when servers are using `Virtual Hosting`_. When such servers are hosting83more than one SSL site they need to be able to return the appropriate84certificate based on the hostname the client is connecting to.8586Python3 and Python 2.7.9+ include native support for SNI in their SSL modules.87For information on using SNI with Requests on Python < 2.7.9 refer to this88`Stack Overflow answer`_.86Python 3 already includes native support for SNI in their SSL modules.8788.. _`Server-Name-Indication`: https://en.wikipedia.org/wiki/Server_Name_Indication89.. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting92.. _`Stack Overflow answer`: https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/18579484#18579484
modified:docs/index.rst+1 added-1 removed
70 unmodified lines
71- Connection Timeouts72- Chunked Requests73- ``.netrc`` Support7475Requests officially supports Python 2.7 & 3.6+, and runs great on PyPy.75Requests officially supports Python 3.7+, and runs great on PyPy.767778The User Guide79--------------
61 unmodified lines
modified:requests/_internal_utils.py+2 added-5 removed
6 unmodified lines
7Provides utility functions that are consumed internally by Requests8which depend on extremely few external helpers (such as compat)9"""1011from .compat import is_py2, builtin_str, str11from .compat import builtin_str121314def to_native_string(string, encoding='ascii'):15 """Given a string object, regardless of type, returns a representation of
2 unmodified lines
18 """19 if isinstance(string, builtin_str):20 out = string21 else:22 if is_py2:23 out = string.encode(encoding)24 else:25 out = string.decode(encoding)22 out = string.decode(encoding)2324 return out2526
13 unmodified lines
modified:requests/adapters.py+1 added-6 removed
475 unmodified lines
476 low_conn.send(b'\r\n')477 low_conn.send(b'0\r\n\r\n')478479 # Receive the response from the server480 try:481 # For Python 2.7, use buffering of HTTP responses482 r = low_conn.getresponse(buffering=True)483 except TypeError:484 # For compatibility with Python 3.3+485 r = low_conn.getresponse()480 r = low_conn.getresponse()481482 resp = HTTPResponse.from_httplib(483 r,484 pool=conn,
49 unmodified lines
modified:requests/compat.py+24 added-42 removed
2 unmodified lines
3"""4requests.compat5~~~~~~~~~~~~~~~67This module handles import compatibility issues between Python 2 and8Python 3.7This module previously handled import compatibility issues8between Python 2 and Python 3. It remains for backwards9compatibility until the next major version.10"""1112try:13 import chardet
14 unmodified lines
2829#: Python 3.x?30is_py3 = (_ver[0] == 3)3132# json/simplejson module import resolution33has_simplejson = False34try:35 import simplejson as json36 has_simplejson = True37except ImportError:38 import json3940if has_simplejson:41 from simplejson import JSONDecodeError42else:43 from json import JSONDecodeError4445# ---------39# Specifics46# Legacy Imports47# ---------48from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag49from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment50from http import cookiejar as cookielib51from http.cookies import Morsel52from io import StringIO5342if is_py2:43 from urllib import (44 quote, unquote, quote_plus, unquote_plus, urlencode, getproxies,45 proxy_bypass, proxy_bypass_environment, getproxies_environment)46 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag47 from urllib2 import parse_http_list48 import cookielib49 from Cookie import Morsel50 from StringIO import StringIO51 # Keep OrderedDict for backwards compatibility.52 from collections import Callable, Mapping, MutableMapping, OrderedDict54# Keep OrderedDict for backwards compatibility.55from collections import OrderedDict56from collections.abc import Callable, Mapping, MutableMapping5754 builtin_str = str55 bytes = str56 str = unicode57 basestring = basestring58 numeric_types = (int, long, float)59 integer_types = (int, long)60 JSONDecodeError = ValueError6162elif is_py3:63 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag64 from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment65 from http import cookiejar as cookielib66 from http.cookies import Morsel67 from io import StringIO68 # Keep OrderedDict for backwards compatibility.69 from collections import OrderedDict70 from collections.abc import Callable, Mapping, MutableMapping71 if has_simplejson:72 from simplejson import JSONDecodeError73 else:74 from json import JSONDecodeError7576 builtin_str = str77 str = str78 bytes = bytes79 basestring = (str, bytes)80 numeric_types = (int, float)81 integer_types = (int,)58builtin_str = str59str = str60bytes = bytes61basestring = (str, bytes)62numeric_types = (int, float)63integer_types = (int,)
modified:requests/help.py+2 added-2 removed
34 unmodified lines
35def _implementation():36 """Return a dict with the Python implementation and version.3738 Provide both the name and the version of the Python implementation39 currently running. For example, on CPython 2.7.5 it will return40 {'name': 'CPython', 'version': '2.7.5'}.39 currently running. For example, on CPython 3.10.3 it will return40 {'name': 'CPython', 'version': '3.10.3'}.4142 This function works best on CPython and PyPy: in particular, it probably43 doesn't work for Jython or IronPython. Future investigation should be done44 to work out the correct shape of the code for those platforms.
91 unmodified lines
modified:requests/models.py+4 added-20 removed
6 unmodified lines
7This module contains the primary objects that power Requests.8"""910import datetime11import sys1112# Import encoding now, to avoid implicit import later.13# Implicit import within threads may cause LookupError when standard library is in a ZIP,14# such as in Embedded Python. See https://github.com/psf/requests/issues/3578.
28 unmodified lines
43 stream_decode_response_unicode, to_key_val_list, parse_header_links,44 iter_slices, guess_json_utf, super_len, check_header_validity)45from .compat import (46 Callable, Mapping,48 cookielib, urlunparse, urlsplit, urlencode, str, bytes,49 is_py2, chardet, builtin_str, basestring, JSONDecodeError)47 cookielib, urlunparse, urlsplit, urlencode,48 chardet, builtin_str, basestring, JSONDecodeError)49from .compat import json as complexjson50from .status_codes import codes5152#: The set of HTTP status codes that indicate an automatically
318 unmodified lines
371 #: https://github.com/psf/requests/pull/2238372 if isinstance(url, bytes):373 url = url.decode('utf8')374 else:376 url = unicode(url) if is_py2 else str(url)375 url = str(url)376377 # Remove leading whitespaces from url378 url = url.lstrip()379
42 unmodified lines
422 # Bare domains aren't valid URLs.423 if not path:424 path = '/'425427 if is_py2:428 if isinstance(scheme, str):429 scheme = scheme.encode('utf-8')430 if isinstance(netloc, str):431 netloc = netloc.encode('utf-8')432 if isinstance(path, str):433 path = path.encode('utf-8')434 if isinstance(query, str):435 query = query.encode('utf-8')436 if isinstance(fragment, str):437 fragment = fragment.encode('utf-8')438426 if isinstance(params, (str, bytes)):427 params = to_native_string(params)428429 enc_params = self._encode_params(params)
475 unmodified lines
905 return complexjson.loads(self.text, **kwargs)906 except JSONDecodeError as e:907 # Catch JSON-related errors and raise as requests.JSONDecodeError908 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError922 if is_py2: # e is a ValueError923 raise RequestsJSONDecodeError(e.message)924 else:925 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)909 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)910911 @property912 def links(self):913 """Returns the parsed header links of the response, if any."""
52 unmodified lines
modified:requests/sessions.py+3 added-7 removed
12 unmodified lines
13from datetime import timedelta14from collections import OrderedDict1516from .auth import _basic_auth_str17from .compat import cookielib, is_py3, urljoin, urlparse, Mapping17from .compat import cookielib, urljoin, urlparse, Mapping18from .cookies import (19 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)20from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT21from .hooks import default_hooks, dispatch_hook
16 unmodified lines
38from .models import REDIRECT_STATI3940# Preferred clock, based on which one is more accurate on a given system.41if sys.platform == 'win32':42 try: # Python 3.4+43 preferred_clock = time.perf_counter42 preferred_clock = time.perf_counter44 except AttributeError: # Earlier than Python 3.45 preferred_clock = time.clock43else:44 preferred_clock = time.time4546
60 unmodified lines
107 # rarely used with non-ASCII characters in HTTP headers.108 # It is more likely to get UTF8 header rather than latin1.109 # This causes incorrect handling of UTF8 encoded location headers.110 # To solve this, we re-encode the location in latin1.114 if is_py3:115 location = location.encode('latin1')111 location = location.encode('latin1')112 return to_native_string(location, 'utf8')113 return None114115 def should_strip_auth(self, old_url, new_url):
659 unmodified lines
modified:requests/utils.py+3 added-7 removed
28 unmodified lines
29from ._internal_utils import to_native_string30from .compat import parse_http_list as _parse_list_header31from .compat import (32 quote, urlparse, bytes, str, unquote, getproxies,33 proxy_bypass, urlunparse, basestring, integer_types, is_py3,33 proxy_bypass, urlunparse, basestring, integer_types,34 proxy_bypass_environment, getproxies_environment, Mapping)35from .cookies import cookiejar_from_dict36from .structures import CaseInsensitiveDict37from .exceptions import (
15 unmodified lines
53 # provide a proxy_bypass version on Windows without DNS lookups5455 def proxy_bypass_registry(host):56 try:57 if is_py3:58 import winreg57 import winreg59 else:60 import _winreg as winreg58 except ImportError:59 return False6061 try:
215 unmodified lines
277278@contextlib.contextmanager279def atomic_open(filename):280 """Write a file to the disk in an atomic fashion"""284 replacer = os.rename if sys.version_info[0] == 2 else os.replace281 tmp_descriptor, tmp_name = tempfile.mkstemp(dir=os.path.dirname(filename))282 try:283 with os.fdopen(tmp_descriptor, 'wb') as tmp_handler:284 yield tmp_handler289 replacer(tmp_name, filename)285 os.replace(tmp_name, filename)286 except BaseException:287 os.remove(tmp_name)288 raise289
767 unmodified lines
modified:tests/testserver/server.py+1 added-3 removed
76 unmodified lines
7778 def _create_socket_and_bind(self):79 sock = socket.socket()80 sock.bind((self.host, self.port))81 # NB: when Python 2.7 is no longer supported, the argument82 # can be removed to use a default backlog size83 sock.listen(5)81 sock.listen()82 return sock8384 def _close_server_sock_ignore_errors(self):85 try:
43 unmodified lines
modified:tests/compat.py+12 added-9 removed
1# -*- coding: utf-8 -*-2import warnings33from requests.compat import is_py3454try:5 import StringIO6except ImportError:7 import io as StringIO
2 unmodified lines
10 from cStringIO import StringIO as cStringIO11except ImportError:12 cStringIO = None1316if is_py3:17 def u(s):18 return s19else:20 def u(s):21 return s.decode('unicode-escape')1415def u(s):16 warnings.warn(17 (18 "This helper function is no longer relevant in Python 3. "19 "Usage of this alias should be discontinued as it will be "20 "removed in a future release of Requests."21 ),22 DeprecationWarning,23 )24 return s
modified:tests/test_requests.py+32 added-36 removed
1# -*- coding: utf-8 -*-23"""Tests for Requests."""45from __future__ import division5import json6import os7import pickle8import collections
7 unmodified lines
16import urllib317from requests.adapters import HTTPAdapter18from requests.auth import HTTPDigestAuth, _basic_auth_str19from requests.compat import (21 Morsel, cookielib, getproxies, str, urlparse,20 Morsel, cookielib, getproxies, urlparse,21 builtin_str)22from requests.cookies import (23 cookiejar_from_dict, morsel_to_cookie)24from requests.exceptions import (
20 unmodified lines
45from requests.structures import CaseInsensitiveDict46from requests.sessions import SessionRedirectMixin47from requests.models import urlencode48from requests.hooks import default_hooks50from requests.compat import JSONDecodeError, is_py3, MutableMapping49from requests.compat import JSONDecodeError, MutableMapping5052from .compat import StringIO, u51from .compat import StringIO52from .utils import override_environ53from urllib3.util import Timeout as Urllib3Timeout5455# Requests to this URL should always fail with a connection timeout (nothing
461 unmodified lines
517518 @pytest.mark.parametrize(519 'username, password', (520 ('user', 'pass'),522 (u'имя'.encode('utf-8'), u'пароль'.encode('utf-8')),521 ('имя'.encode('utf-8'), 'пароль'.encode('utf-8')),522 (42, 42),523 (None, None),524 ))525 def test_set_basicauth(self, httpbin, username, password):
315 unmodified lines
841 url = httpbin('post')842 with open('requirements-dev.txt') as f:843 with pytest.raises(ValueError):844 requests.post(url, data='[{"some": "data"}]', files={'some': f})846 with pytest.raises(ValueError):847 requests.post(url, data=u('[{"some": "data"}]'), files={'some': f})845846 def test_request_ok_set(self, httpbin):847 r = requests.get(httpbin('status', '404'))848 assert not r.ok
136 unmodified lines
985 assert r.status_code == 200986987 @pytest.mark.parametrize(988 'data', (992 {'stuff': u('ëlïxr')},993 {'stuff': u('ëlïxr').encode('utf-8')},989 {'stuff': 'ëlïxr'},990 {'stuff': 'ëlïxr'.encode('utf-8')},991 {'stuff': 'elixr'},992 {'stuff': 'elixr'.encode('utf-8')},993 ))994 def test_unicode_multipart_post(self, httpbin, data):
14 unmodified lines
10091010 def test_unicode_method_name(self, httpbin):1011 files = {'file': open(__file__, 'rb')}1012 r = requests.request(1016 method=u('POST'), url=httpbin('post'), files=files)1013 method='POST', url=httpbin('post'), files=files)1014 assert r.status_code == 20010151016 def test_unicode_method_name_with_request_object(self, httpbin):1017 files = {'file': open(__file__, 'rb')}1018 s = requests.Session()1022 req = requests.Request(u('POST'), httpbin('post'), files=files)1019 req = requests.Request('POST', httpbin('post'), files=files)1020 prep = s.prepare_request(req)1021 assert isinstance(prep.method, builtin_str)1022 assert prep.method == 'POST'1023
1 unmodified line
1025 assert resp.status_code == 20010261027 def test_non_prepared_request_error(self):1028 s = requests.Session()1032 req = requests.Request(u('POST'), '/')1029 req = requests.Request('POST', '/')10301031 with pytest.raises(ValueError) as e:1032 s.send(req)1033 assert str(e.value) == 'You can only send PreparedRequests.'
298 unmodified lines
13321333 def test_response_reason_unicode(self):1334 # check for unicode HTTP status1335 r = requests.Response()1339 r.url = u'unicode URL'1340 r.reason = u'Komponenttia ei löydy'.encode('utf-8')1336 r.url = 'unicode URL'1337 r.reason = 'Komponenttia ei löydy'.encode('utf-8')1338 r.status_code = 4041339 r.encoding = None1340 assert not r.ok # old behaviour - crashes here13411342 def test_response_reason_unicode_fallback(self):1343 # check raise_status falls back to ISO-8859-11344 r = requests.Response()1345 r.url = 'some url'1349 reason = u'Komponenttia ei löydy'1346 reason = 'Komponenttia ei löydy'1347 r.reason = reason.encode('latin-1')1348 r.status_code = 5001349 r.encoding = None1350 with pytest.raises(requests.exceptions.HTTPError) as e:
238 unmodified lines
1589 r = requests.Request('GET', url).prepare()1590 assert r.url == url15911592 def test_header_keys_are_native(self, httpbin):1596 headers = {u('unicode'): 'blah', 'byte'.encode('ascii'): 'blah'}1593 headers = {'unicode': 'blah', 'byte'.encode('ascii'): 'blah'}1594 r = requests.Request('GET', httpbin('get'), headers=headers)1595 p = r.prepare()15961597 # This is testing that they are builtin strings. A bit weird, but there
3 unmodified lines
16011602 def test_header_validation(self, httpbin):1603 """Ensure prepare_headers regex isn't flagging valid header contents."""1604 headers_ok = {'foo': 'bar baz qux',1608 'bar': u'fbbq'.encode('utf8'),1605 'bar': 'fbbq'.encode('utf8'),1606 'baz': '',1607 'qux': '1'}1608 r = requests.get(httpbin('get'), headers=headers_ok)1609 assert r.request.headers['foo'] == headers_ok['foo']
271 unmodified lines
18811882 @pytest.mark.parametrize(1883 'username, password, auth_str', (1884 ('test', 'test', 'Basic dGVzdDp0ZXN0'),1888 (u'имя'.encode('utf-8'), u'пароль'.encode('utf-8'), 'Basic 0LjQvNGPOtC/0LDRgNC+0LvRjA=='),1885 ('имя'.encode('utf-8'), 'пароль'.encode('utf-8'), 'Basic 0LjQvNGPOtC/0LDRgNC+0LvRjA=='),1886 ))1887 def test_basic_auth_str_is_always_native(self, username, password, auth_str):1888 s = _basic_auth_str(username, password)1889 assert isinstance(s, builtin_str)
575 unmodified lines
2465 'cookies': {'foo': 'bar'}2466 },2467 {2468 'method': 'GET',2472 'url': u('http://www.example.com/üniçø∂é')2469 'url': 'http://www.example.com/üniçø∂é'2470 },2471 ))2472def test_prepared_copy(kwargs):2473 p = PreparedRequest()
29 unmodified lines
2503 @pytest.mark.parametrize(2504 'url,expected',2505 (2506 ('http://google.com', 'http://google.com/'),2510 (u'http://ジェーピーニック.jp', u'http://xn--hckqz9bzb1cyrb.jp/'),2511 (u'http://xn--n3h.net/', u'http://xn--n3h.net/'),2507 ('http://ジェーピーニック.jp', 'http://xn--hckqz9bzb1cyrb.jp/'),2508 ('http://xn--n3h.net/', 'http://xn--n3h.net/'),2509 (2513 u'http://ジェーピーニック.jp'.encode('utf-8'),2514 u'http://xn--hckqz9bzb1cyrb.jp/'2510 'http://ジェーピーニック.jp'.encode('utf-8'),2511 'http://xn--hckqz9bzb1cyrb.jp/'2512 ),2513 (2517 u'http://straße.de/straße',2518 u'http://xn--strae-oqa.de/stra%C3%9Fe'2514 'http://straße.de/straße',2515 'http://xn--strae-oqa.de/stra%C3%9Fe'2516 ),2517 (2521 u'http://straße.de/straße'.encode('utf-8'),2522 u'http://xn--strae-oqa.de/stra%C3%9Fe'2518 'http://straße.de/straße'.encode('utf-8'),2519 'http://xn--strae-oqa.de/stra%C3%9Fe'2520 ),2521 (2525 u'http://Königsgäßchen.de/straße',2526 u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2522 'http://Königsgäßchen.de/straße',2523 'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2524 ),2525 (2529 u'http://Königsgäßchen.de/straße'.encode('utf-8'),2530 u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2526 'http://Königsgäßchen.de/straße'.encode('utf-8'),2527 'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2528 ),2529 (2530 b'http://xn--n3h.net/',2534 u'http://xn--n3h.net/'2531 'http://xn--n3h.net/'2532 ),2533 (2534 b'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2538 u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2535 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2536 ),2537 (2541 u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2542 u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2538 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2539 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2540 )2541 )2542 )2543 def test_preparing_url(self, url, expected):
116 unmodified lines
2660 assert isinstance(excinfo.value, RequestException)2661 assert isinstance(excinfo.value, JSONDecodeError)2662 assert r.text not in str(excinfo.value)26632667 @pytest.mark.skipif(not is_py3, reason="doc attribute is only present on py3")2664 def test_json_decode_persists_doc_attr(self, httpbin):2665 r = requests.get(httpbin('bytes/20'))2666 with pytest.raises(requests.exceptions.JSONDecodeError) as excinfo:2667 r.json()
1 unmodified line
modified:tests/test_utils.py+1 added-4 removed
747 unmodified lines
748 can be bypassed or not with Windows registry settings749 """750 if override is None:751 override = '192.168.*;127.0.0.1;localhost.localdomain;172.16.1.1'752 if compat.is_py3:753 import winreg752 import winreg754 else:755 import _winreg as winreg753754 class RegHandle:755 def Close(self):756 pass
50 unmodified lines
modified:HISTORY.md+5 added
9 unmodified lines
1011- Fixed urllib3 exception leak, wrapping `urllib3.exceptions.SSLError` with12 `requests.exceptions.SSLError` for `content` and `iter_content`.1314**Deprecations**1516- ⚠️ Requests has officially dropped support for Python 2.7. ⚠️17- Requests has officially dropped support for Python 3.6 (including pypy3).18192.27.1 (2022-01-05)20-------------------2122**Bugfixes**
1795 unmodified lines
modified:README.md+1 added-1 removed
31 unmodified lines
32```console33$ python -m pip install requests34```3536Requests officially supports Python 2.7 & 3.6+.36Requests officially supports Python 3.7+.3738## Supported Features & Best–Practices3940Requests is ready for the demands of building robust and reliable HTTP–speaking applications, for the needs of today.
38 unmodified lines
modified:setup.cfg+8 added-3 removed
1[bdist_wheel]2universal = 131[metadata]2license_file = LICENSE3provides-extra =4 socks5 use_chardet_on_py36requires-dist =7 certifi>=2017.4.178 charset_normalizer~=2.0.09 idna>=2.5,<410 urllib3>=1.21.1,<1.27
modified:setup.py+30 added-17 removed
1#!/usr/bin/env python2# Learn more: https://github.com/kennethreitz/setup.py2import os3import sys45from codecs import open67from setuptools import setup8from setuptools.command.test import test as TestCommand911here = os.path.abspath(os.path.dirname(__file__))1011CURRENT_PYTHON = sys.version_info[:2]12REQUIRED_PYTHON = (3, 7)1314if CURRENT_PYTHON < REQUIRED_PYTHON:15 sys.stderr.write(16 """17==========================18Unsupported Python version19==========================20This version of Requests requires at least Python {}.{}, but21you're trying to install it on Python {}.{}. To resolve this,22consider upgrading to a supported Python version.2324If you can't upgrade your Python version, you'll need to25pin to an older version of Requests (<2.28).26""".format(27 *(REQUIRED_PYTHON + CURRENT_PYTHON)28 )29 )30 sys.exit(1)3132class PyTest(TestCommand):33 user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]3435 def initialize_options(self):
20 unmodified lines
56 os.system('python setup.py sdist bdist_wheel')57 os.system('twine upload dist/*')58 sys.exit()5941packages = ['requests']4260requires = [44 'charset_normalizer~=2.0.0; python_version >= "3"',45 'chardet>=3.0.2,<5; python_version < "3"',46 'idna>=2.5,<3; python_version < "3"',47 'idna>=2.5,<4; python_version >= "3"',61 'charset_normalizer~=2.0.0',62 'idna>=2.5,<4',63 'urllib3>=1.21.1,<1.27',49 'certifi>=2017.4.17'5064 'certifi>=2017.4.17',65]66test_requirements = [67 'pytest-httpbin==0.0.7',68 'pytest-cov',69 'pytest-mock',70 'pytest-xdist',71 'PySocks>=1.5.6, !=1.5.7',58 'pytest>=3'72 'pytest>=3',73]7475about = {}76here = os.path.abspath(os.path.dirname(__file__))77with open(os.path.join(here, 'requests', '__version__.py'), 'r', 'utf-8') as f:78 exec(f.read(), about)7980with open('README.md', 'r', 'utf-8') as f:
7 unmodified lines
88 long_description_content_type='text/markdown',89 author=about['__author__'],90 author_email=about['__author_email__'],91 url=about['__url__'],77 packages=packages,92 packages=['requests'],93 package_data={'': ['LICENSE', 'NOTICE']},94 package_dir={'requests': 'requests'},95 include_package_data=True,81 python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",96 python_requires=">=3.7, <4",97 install_requires=requires,98 license=about['__license__'],99 zip_safe=False,100 classifiers=[
3 unmodified lines
104 'License :: OSI Approved :: Apache Software License',105 'Natural Language :: English',106 'Operating System :: OS Independent',107 'Programming Language :: Python',93 'Programming Language :: Python :: 2',94 'Programming Language :: Python :: 2.7',108 'Programming Language :: Python :: 3',96 'Programming Language :: Python :: 3.6',109 'Programming Language :: Python :: 3.7',110 'Programming Language :: Python :: 3.8',111 'Programming Language :: Python :: 3.9',112 'Programming Language :: Python :: 3.10',113 'Programming Language :: Python :: 3.11',114 'Programming Language :: Python :: 3 :: Only',115 'Programming Language :: Python :: Implementation :: CPython',116 'Programming Language :: Python :: Implementation :: PyPy',117 'Topic :: Internet :: WWW/HTTP',118 'Topic :: Software Development :: Libraries',
2 unmodified lines
121 tests_require=test_requirements,122 extras_require={123 'security': [],124 'socks': ['PySocks>=1.5.6, !=1.5.7'],111 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],125 'use_chardet_on_py3': ['chardet>=3.0.2,<5']126 },127 project_urls={128 'Documentation': 'https://requests.readthedocs.io',
3 unmodified lines
modified:tox.ini+1 added-1 removed
1[tox]2envlist = py{27,36,37,38,39}-{default,use_chardet_on_py3}2envlist = py{37,38,39,310}-{default, use_chardet_on_py3}34[testenv]5deps = -rrequirements-dev.txt6extras =
12 unmodified lines