mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Remove requests as dependency (#26083)
Summary: local build is slow... test in CI... Pull Request resolved: https://github.com/pytorch/pytorch/pull/26083 Differential Revision: D17346949 Pulled By: ailzhang fbshipit-source-id: f552d1a4be55ad4e2bd915af7c5a2c1b6667c446
This commit is contained in:
parent
07e7c7eb9f
commit
079cd4e1fc
5 changed files with 10 additions and 30 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
3
setup.py
3
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}`
|
||||
|
|
|
|||
29
torch/hub.py
29
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue