Repository: pypa/virtualenv

Issue:
Unstated dependency on pip >= 10
If you are in the situation where you have an old version of pip < 10, virtualenv 16.3.0 will happily install, but fails when you try to create a virtualenv because it's shelling out to `pip -m config`, which was [added in pip 10](https://pip.pypa.io/en/stable/news/#b1-2018-03-31). Virtualenv does not appear to declare a dependency on pip and the [Installation docs](https://virtualenv.pypa.io/en/latest/installation/) only say that pip > 1.3 is recommended.

```
$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

$ pip list | grep virtualenv
virtualenv (16.3.0)

$ virtualenv /tmp/venv
New python executable in /tmp/venv/bin/python
Complete output from command /tmp/venv/bin/python -m pip config list:
ERROR: unknown command "config"
----------------------------------------
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 793, in main
    symlink=options.symlink,
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1087, in create_environment
    install_wheel(to_install, py_executable, search_dirs, download=download)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 935, in install_wheel
    _install_wheel_with_search_dir(download, project_names, py_executable, search_dirs)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 964, in _install_wheel_with_search_dir
    config = _pip_config(py_executable, python_path)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1038, in _pip_config
    remove_from_env=["PIP_VERBOSE", "PIP_QUIET"],
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 886, in call_subprocess
    raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))
OSError: Command /tmp/venv/bin/python -m pip config list failed with error code 1
```


Discussion:
I think we can still work in this case, just disable this feature. 👍 

Resolving patch:
diff --git a/virtualenv.py b/virtualenv.py
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1036,6 +1036,7 @@ def _pip_config(py_executable, python_path):
         show_stdout=False,
         extra_env={"PYTHONPATH": python_path, "JYTHONPATH": python_path},
         remove_from_env=["PIP_VERBOSE", "PIP_QUIET"],
+        raise_on_return_code=False,
     ):
         key, _, value = line.partition("=")
         if value:


Test patch:
diff --git a/tests/old-wheels/pip-9.0.1-py2.py3-none-any.whl b/tests/old-wheels/pip-9.0.1-py2.py3-none-any.whl
new file mode 100644
Binary files /dev/null and b/tests/old-wheels/pip-9.0.1-py2.py3-none-any.whl differ
diff --git a/tests/old-wheels/setuptools-30.4.0-py2.py3-none-any.whl b/tests/old-wheels/setuptools-30.4.0-py2.py3-none-any.whl
new file mode 100644
Binary files /dev/null and b/tests/old-wheels/setuptools-30.4.0-py2.py3-none-any.whl differ
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -552,3 +552,15 @@ def test_create_environment_from_virtual_environment(tmpdir):
     home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(venvdir)
     virtualenv.create_environment(venvdir)
     assert not os.path.islink(os.path.join(lib_dir, "distutils"))
+
+
+def test_create_environment_with_old_pip(tmpdir):
+    old = Path(__file__).parent / "old-wheels"
+    old_pip = old / "pip-9.0.1-py2.py3-none-any.whl"
+    old_setuptools = old / "setuptools-30.4.0-py2.py3-none-any.whl"
+    support_dir = str(tmpdir / "virtualenv_support")
+    os.makedirs(support_dir)
+    for old_dep in [old_pip, old_setuptools]:
+        shutil.copy(str(old_dep), support_dir)
+    venvdir = str(tmpdir / "venv")
+    virtualenv.create_environment(venvdir, search_dirs=[support_dir], no_wheel=True)