Repository: pypa/setuptools

Issue:
Impossible to install packages with setuptools v.40.6.x, if six isn't installed
Upgrade pip and setuptools to latest versions

```
oleg$ pip install --upgrade pip setuptools
Collecting pip
  Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/4b/47/1417da90ed6f4c88465d08ea2461ff41c94cc6cc223f333d130d7a99199a/setuptools-40.6.1-py2.py3-none-any.whl
Installing collected packages: pip, setuptools
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
  Found existing installation: setuptools 38.2.4
    Uninstalling setuptools-38.2.4:
      Successfully uninstalled setuptools-38.2.4
Successfully installed pip-18.1 setuptools-40.6.1
```

Try to install any package, d2to1 for example

```
oleg$ pip install d2to1
Collecting d2to1
  Downloading https://files.pythonhosted.org/packages/dc/bd/eac45e4e77d76f6c0ae539819c40f1babb891d7855129663e37957a7c2df/d2to1-0.2.12.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/ns/71p61z5s3hsd2pv327gmdh1c0000gn/T/pip-install-2J_LhF/d2to1/setup.py", line 17, in <module>
        setup(**cfg_to_args())
      File "d2to1/util.py", line 204, in cfg_to_args
        wrap_commands(kwargs)
      File "d2to1/util.py", line 439, in wrap_commands
        for cmd, _ in dist.get_command_list():
      File "/Users/oleg/.virtualenvs/yandex/lib/python2.7/site-packages/setuptools/dist.py", line 724, in get_command_list
        cmdclass = ep.resolve()
      File "/Users/oleg/.virtualenvs/yandex/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2352, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
      File "/Users/oleg/.virtualenvs/yandex/lib/python2.7/site-packages/setuptools/command/upload_docs.py", line 23, in <module>
        from .upload import upload
      File "/Users/oleg/.virtualenvs/yandex/lib/python2.7/site-packages/setuptools/command/upload.py", line 15, in <module>
        from six.moves.urllib.request import urlopen, Request
    ImportError: No module named six.moves.urllib.request
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/ns/71p61z5s3hsd2pv327gmdh1c0000gn/T/pip-install-2J_LhF/d2to1/
````

```
oleg$ pip list
Package    Version     
---------- ------------
d2to1      0.2.12.post1
pip        18.1        
setuptools 40.6.1      
wheel      0.30.0
```

Downgrade setuptools to v.40.5.0, and try installation again

```
oleg$ pip install --upgrade setuptools==40.5.0
Collecting setuptools==40.5.0
  Downloading https://files.pythonhosted.org/packages/82/a1/ba6fb41367b375f5cb653d1317d8ca263c636cff6566e2da1b0da716069d/setuptools-40.5.0-py2.py3-none-any.whl (569kB)
    100% |████████████████████████████████| 573kB 754kB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 40.6.1
    Uninstalling setuptools-40.6.1:
      Successfully uninstalled setuptools-40.6.1
Successfully installed setuptools-40.5.0

oleg$ pip install d2to1
Collecting d2to1
  Using cached https://files.pythonhosted.org/packages/dc/bd/eac45e4e77d76f6c0ae539819c40f1babb891d7855129663e37957a7c2df/d2to1-0.2.12.post1.tar.gz
Requirement already satisfied: setuptools in /Users/oleg/.virtualenvs/yandex/lib/python2.7/site-packages (from d2to1) (40.5.0)
Building wheels for collected packages: d2to1
  Running setup.py bdist_wheel for d2to1 ... done
  Stored in directory: /Users/oleg/Library/Caches/pip/wheels/e6/1a/ed/11531583d510d72448e39bfc254147d0e7b2b2ad65722b3a6f
Successfully built d2to1
Installing collected packages: d2to1
Successfully installed d2to1-0.2.12.post1
```


Discussion:

Resolving patch:
diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py
--- a/setuptools/command/upload.py
+++ b/setuptools/command/upload.py
@@ -12,9 +12,9 @@
 
 from distutils.errors import DistutilsError
 
-from six.moves.urllib.request import urlopen, Request
-from six.moves.urllib.error import HTTPError
-from six.moves.urllib.parse import urlparse
+from setuptools.extern.six.moves.urllib.request import urlopen, Request
+from setuptools.extern.six.moves.urllib.error import HTTPError
+from setuptools.extern.six.moves.urllib.parse import urlparse
 
 class upload(orig.upload):
     """


Test patch:
diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py
--- a/setuptools/tests/test_dist.py
+++ b/setuptools/tests/test_dist.py
@@ -7,13 +7,12 @@
 from setuptools import Distribution
 from setuptools.extern.six.moves.urllib.request import pathname2url
 from setuptools.extern.six.moves.urllib_parse import urljoin
+from setuptools.extern import six
 
 from .textwrap import DALS
 from .test_easy_install import make_nspkg_sdist
 
 import pytest
-import six
-
 
 def test_dist_fetch_build_egg(tmpdir):
     """
diff --git a/setuptools/tests/test_upload.py b/setuptools/tests/test_upload.py
--- a/setuptools/tests/test_upload.py
+++ b/setuptools/tests/test_upload.py
@@ -7,10 +7,10 @@
 from distutils.version import StrictVersion
 
 import pytest
-import six
 
 from setuptools.command.upload import upload
 from setuptools.dist import Distribution
+from setuptools.extern import six
 
 
 def _parse_upload_body(body):
diff --git a/tests/manual_test.py b/tests/manual_test.py
--- a/tests/manual_test.py
+++ b/tests/manual_test.py
@@ -8,7 +8,7 @@
 from distutils.command.install import INSTALL_SCHEMES
 from string import Template
 
-from six.moves import urllib
+from setuptools.extern.six.moves import urllib
 
 
 def _system_call(*args):