Unverified Commit 42b8d462 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

Remove six dependency (#2017)

* remove six from python code

* remove six from setup.py

* remove six from tests

* remove six from references

* remove six from packaging

* revert str to torch._six._string_classes

* revert str to torch._six._string_classes
parent e1bd43cb
...@@ -20,7 +20,6 @@ requirements: ...@@ -20,7 +20,6 @@ requirements:
- python - python
- pillow >=4.1.1 - pillow >=4.1.1
- numpy >=1.11 - numpy >=1.11
- six
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }} {{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }} {{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
......
...@@ -69,7 +69,6 @@ if os.getenv('PYTORCH_VERSION'): ...@@ -69,7 +69,6 @@ if os.getenv('PYTORCH_VERSION'):
requirements = [ requirements = [
'numpy', 'numpy',
'six',
pytorch_dep, pytorch_dep,
] ]
......
...@@ -11,7 +11,7 @@ import errno ...@@ -11,7 +11,7 @@ import errno
import __main__ import __main__
from numbers import Number from numbers import Number
from torch._six import string_classes, inf from torch._six import string_classes
from collections import OrderedDict from collections import OrderedDict
...@@ -255,6 +255,7 @@ class TestCase(unittest.TestCase): ...@@ -255,6 +255,7 @@ class TestCase(unittest.TestCase):
elif isinstance(x, bool) and isinstance(y, bool): elif isinstance(x, bool) and isinstance(y, bool):
super(TestCase, self).assertEqual(x, y, message) super(TestCase, self).assertEqual(x, y, message)
elif isinstance(x, Number) and isinstance(y, Number): elif isinstance(x, Number) and isinstance(y, Number):
inf = float("inf")
if abs(x) == inf or abs(y) == inf: if abs(x) == inf or abs(y) == inf:
if allow_inf: if allow_inf:
super(TestCase, self).assertEqual(x, y, message) super(TestCase, self).assertEqual(x, y, message)
......
...@@ -7,7 +7,6 @@ import zipfile ...@@ -7,7 +7,6 @@ import zipfile
import tarfile import tarfile
import gzip import gzip
import warnings import warnings
from torch._six import PY2
from torch._utils_internal import get_file_path_2 from torch._utils_internal import get_file_path_2
from common_utils import get_tmp_dir from common_utils import get_tmp_dir
...@@ -41,7 +40,6 @@ class Tester(unittest.TestCase): ...@@ -41,7 +40,6 @@ class Tester(unittest.TestCase):
self.assertTrue(utils.check_integrity(existing_fpath)) self.assertTrue(utils.check_integrity(existing_fpath))
self.assertFalse(utils.check_integrity(nonexisting_fpath)) self.assertFalse(utils.check_integrity(nonexisting_fpath))
@unittest.skipIf(PY2, "https://github.com/pytorch/vision/issues/1268")
def test_download_url(self): def test_download_url(self):
with get_tmp_dir() as temp_dir: with get_tmp_dir() as temp_dir:
url = "http://github.com/pytorch/vision/archive/master.zip" url = "http://github.com/pytorch/vision/archive/master.zip"
...@@ -53,7 +51,6 @@ class Tester(unittest.TestCase): ...@@ -53,7 +51,6 @@ class Tester(unittest.TestCase):
warnings.warn(msg, RuntimeWarning) warnings.warn(msg, RuntimeWarning)
raise unittest.SkipTest(msg) raise unittest.SkipTest(msg)
@unittest.skipIf(PY2, "https://github.com/pytorch/vision/issues/1268")
def test_download_url_retry_http(self): def test_download_url_retry_http(self):
with get_tmp_dir() as temp_dir: with get_tmp_dir() as temp_dir:
url = "https://github.com/pytorch/vision/archive/master.zip" url = "https://github.com/pytorch/vision/archive/master.zip"
......
from collections import defaultdict from collections import defaultdict
from PIL import Image from PIL import Image
from six.moves import html_parser from html.parser import HTMLParser
import glob import glob
import os import os
from .vision import VisionDataset from .vision import VisionDataset
class Flickr8kParser(html_parser.HTMLParser): class Flickr8kParser(HTMLParser):
"""Parser for extracting captions from the Flickr8k dataset web page.""" """Parser for extracting captions from the Flickr8k dataset web page."""
def __init__(self, root): def __init__(self, root):
......
...@@ -2,7 +2,7 @@ from .vision import VisionDataset ...@@ -2,7 +2,7 @@ from .vision import VisionDataset
from PIL import Image from PIL import Image
import os import os
import os.path import os.path
import six import io
import string import string
import sys import sys
...@@ -43,7 +43,7 @@ class LSUNClass(VisionDataset): ...@@ -43,7 +43,7 @@ class LSUNClass(VisionDataset):
with env.begin(write=False) as txn: with env.begin(write=False) as txn:
imgbuf = txn.get(self.keys[index]) imgbuf = txn.get(self.keys[index])
buf = six.BytesIO() buf = io.BytesIO()
buf.write(imgbuf) buf.write(imgbuf)
buf.seek(0) buf.seek(0)
img = Image.open(buf).convert('RGB') img = Image.open(buf).convert('RGB')
......
from PIL import Image from PIL import Image
from six.moves import zip
from .utils import download_url, check_integrity from .utils import download_url, check_integrity
import os import os
......
...@@ -8,7 +8,6 @@ import zipfile ...@@ -8,7 +8,6 @@ import zipfile
import torch import torch
from torch.utils.model_zoo import tqdm from torch.utils.model_zoo import tqdm
from torch._six import PY3
def gen_bar_updater(): def gen_bar_updater():
...@@ -52,7 +51,7 @@ def download_url(url, root, filename=None, md5=None): ...@@ -52,7 +51,7 @@ def download_url(url, root, filename=None, md5=None):
filename (str, optional): Name to save the file under. If None, use the basename of the URL filename (str, optional): Name to save the file under. If None, use the basename of the URL
md5 (str, optional): MD5 checksum of the download. If None, do not check md5 (str, optional): MD5 checksum of the download. If None, do not check
""" """
from six.moves import urllib import urllib
root = os.path.expanduser(root) root = os.path.expanduser(root)
if not filename: if not filename:
...@@ -222,8 +221,7 @@ def extract_archive(from_path, to_path=None, remove_finished=False): ...@@ -222,8 +221,7 @@ def extract_archive(from_path, to_path=None, remove_finished=False):
elif _is_targz(from_path) or _is_tgz(from_path): elif _is_targz(from_path) or _is_tgz(from_path):
with tarfile.open(from_path, 'r:gz') as tar: with tarfile.open(from_path, 'r:gz') as tar:
tar.extractall(path=to_path) tar.extractall(path=to_path)
elif _is_tarxz(from_path) and PY3: elif _is_tarxz(from_path):
# .tar.xz archive only supported in Python 3.x
with tarfile.open(from_path, 'r:xz') as tar: with tarfile.open(from_path, 'r:xz') as tar:
tar.extractall(path=to_path) tar.extractall(path=to_path)
elif _is_gzip(from_path): elif _is_gzip(from_path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment