diff --git a/.jenkins/caffe2/test.sh b/.jenkins/caffe2/test.sh index 0d35d64f7b1..23cfe9bb058 100755 --- a/.jenkins/caffe2/test.sh +++ b/.jenkins/caffe2/test.sh @@ -104,10 +104,6 @@ if [[ "$BUILD_ENVIRONMENT" == *py3* ]]; then export LANG=C.UTF-8 fi -if [[ "$BUILD_ENVIRONMENT" == *py2* ]]; then - pip install --user requests -fi - pip install --user pytest-sugar "$PYTHON" \ -m pytest \ diff --git a/.jenkins/pytorch/test.sh b/.jenkins/pytorch/test.sh index aa2c9d3a9d0..71ade39b263 100755 --- a/.jenkins/pytorch/test.sh +++ b/.jenkins/pytorch/test.sh @@ -56,8 +56,6 @@ if [[ "$BUILD_ENVIRONMENT" != *ppc64le* ]]; then pip_install --user mypy || true fi -pip_install --user requests - # faulthandler become built-in since 3.3 if [[ ! $(python -c "import sys; print(int(sys.version_info >= (3, 3)))") == "1" ]]; then pip_install --user faulthandler diff --git a/README.md b/README.md index 418a7603f4e..cb8f8305d8e 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xa Common ``` -conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing requests +conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing ``` On Linux diff --git a/setup.py b/setup.py index 47e7d87d321..8a1ae82c0c0 100644 --- a/setup.py +++ b/setup.py @@ -352,9 +352,6 @@ install_requires = [] if sys.version_info <= (2, 7): install_requires += ['future'] -if sys.version_info[0] == 2: - install_requires += ['requests'] - missing_pydep = ''' Missing build dependency: Unable to `import {importname}`. Please install it via `conda install {module}` or `pip install {module}` diff --git a/torch/hub.py b/torch/hub.py index b2c072c6b56..d44f5e24f81 100644 --- a/torch/hub.py +++ b/torch/hub.py @@ -12,7 +12,7 @@ import zipfile if sys.version_info[0] == 2: from urlparse import urlparse - import requests + from urllib2 import urlopen # noqa f811 else: from urllib.request import urlopen from urllib.parse import urlparse # noqa: F401 @@ -95,10 +95,7 @@ def _download_archive_zip(url, filename): sys.stderr.write('Downloading: \"{}\" to {}\n'.format(url, filename)) # We use a different API for python2 since urllib(2) doesn't recognize the CA # certificates in older Python - if sys.version_info[0] == 2: - response = requests.get(url, stream=True).raw - else: - response = urlopen(url) + response = urlopen(url) with open(filename, 'wb') as f: while True: data = response.read(READ_DATA_CHUNK) @@ -376,22 +373,14 @@ def _download_url_to_file(url, dst, hash_prefix, progress): file_size = None # We use a different API for python2 since urllib(2) doesn't recognize the CA # certificates in older Python - if sys.version_info[0] == 2: - response = requests.get(url, stream=True) - - content_length = response.headers['Content-Length'] - file_size = int(content_length) - u = response.raw + u = urlopen(url) + meta = u.info() + if hasattr(meta, 'getheaders'): + content_length = meta.getheaders("Content-Length") else: - u = urlopen(url) - - meta = u.info() - if hasattr(meta, 'getheaders'): - content_length = meta.getheaders("Content-Length") - else: - content_length = meta.get_all("Content-Length") - if content_length is not None and len(content_length) > 0: - file_size = int(content_length[0]) + content_length = meta.get_all("Content-Length") + if content_length is not None and len(content_length) > 0: + file_size = int(content_length[0]) # We deliberately save it in a temp file and move it after # download is complete. This prevents a local working checkpoint