Repository: pypa/virtualenv

Issue:
virtualenv "pinned" to setuptools-0.9.8 even when a superior setuptools is installed
I don't know if it's a bug or feature, but seems like a new virtual environment has always setuptools-0.9.8 installed on it, even when a more recent version of setuptools is installed. This is inconvenient, because setuptools-0.9.8 has some known bugs which are now fixed on more recent versions.

I can circumvent the trouble by uninstalling setuptools just after creating a new virtual environment.
In this case, the version of setuptools I've installed into system packages becomes visible again.



Discussion:
Just do pip install -U setuptools.

The reason for the fixed version is to avoid virtualenv calling out to the internet insecurely, which was an issue with the installation process prior to this fix.

I am planning on looking at switching virtualenv to bundle wheels and install from those. When that change lands (it depends on some patches to pip that aren't live yet) it would be possible to allow installation from PyPI again - I'll take that option into consideration when implementing that.

Maybe, for the time being, virtualenv could simply skip installation of setuptools when a more recent version is already installed?

In my case, I actually "pip uninstall setuptools" just after I create a new virtual environment.
Then the system installed version setuptools-1.1.7 becomes visible again.

Thanks :)

know that you can use `--extra-search-dir` to get an alternative version of setuptools.
for awhile that was broke, but it's working in 1.10.1


Resolving patch:
diff --git a/virtualenv.py b/virtualenv.py
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -606,12 +606,19 @@ def main():
               "This option can be used multiple times.")
 
     parser.add_option(
-        '--never-download',
-        dest="never_download",
+        "--download",
+        dest="download",
         action="store_true",
-        default=True,
-        help="DEPRECATED. Retained only for backward compatibility. This option has no effect. "
-              "Virtualenv never downloads pip or setuptools.")
+        help="Download preinstalled packages from PyPI.",
+    )
+
+    parser.add_option(
+        "--no-download",
+        '--never-download',
+        dest="download",
+        action="store_false",
+        help="Do not download preinstalled packages from PyPI.",
+    )
 
     parser.add_option(
         '--prompt',
@@ -682,17 +689,13 @@ def main():
         make_environment_relocatable(home_dir)
         return
 
-    if not options.never_download:
-        logger.warn('The --never-download option is for backward compatibility only.')
-        logger.warn('Setting it to false is no longer supported, and will be ignored.')
-
     create_environment(home_dir,
                        site_packages=options.system_site_packages,
                        clear=options.clear,
                        unzip_setuptools=options.unzip_setuptools,
                        prompt=options.prompt,
                        search_dirs=options.search_dirs,
-                       never_download=True,
+                       download=options.download,
                        no_setuptools=options.no_setuptools,
                        no_pip=options.no_pip,
                        no_wheel=options.no_wheel,
@@ -811,7 +814,8 @@ def find_wheels(projects, search_dirs):
 
     return wheels
 
-def install_wheel(project_names, py_executable, search_dirs=None):
+def install_wheel(project_names, py_executable, search_dirs=None,
+                  download=False):
     if search_dirs is None:
         search_dirs = file_search_dirs()
 
@@ -825,25 +829,29 @@ def install_wheel(project_names, py_executable, search_dirs=None):
     ] + project_names
     logger.start_progress('Installing %s...' % (', '.join(project_names)))
     logger.indent += 2
+
+    env = {
+        "PYTHONPATH": pythonpath,
+        "JYTHONPATH": pythonpath,  # for Jython < 3.x
+        "PIP_FIND_LINKS": findlinks,
+        "PIP_USE_WHEEL": "1",
+        "PIP_ONLY_BINARY": ":all:",
+        "PIP_PRE": "1",
+        "PIP_USER": "0",
+    }
+
+    if not download:
+        env["PIP_NO_INDEX"] = "1"
+
     try:
-        call_subprocess(cmd, show_stdout=False,
-            extra_env = {
-                'PYTHONPATH': pythonpath,
-                'JYTHONPATH': pythonpath,  # for Jython < 3.x
-                'PIP_FIND_LINKS': findlinks,
-                'PIP_USE_WHEEL': '1',
-                'PIP_PRE': '1',
-                'PIP_NO_INDEX': '1',
-                'PIP_USER': '0'
-            }
-        )
+        call_subprocess(cmd, show_stdout=False, extra_env=env)
     finally:
         logger.indent -= 2
         logger.end_progress()
 
 def create_environment(home_dir, site_packages=False, clear=False,
                        unzip_setuptools=False,
-                       prompt=None, search_dirs=None, never_download=False,
+                       prompt=None, search_dirs=None, download=False,
                        no_setuptools=False, no_pip=False, no_wheel=False,
                        symlink=True):
     """
@@ -869,7 +877,12 @@ def create_environment(home_dir, site_packages=False, clear=False,
             to_install.append('pip')
         if not no_wheel:
             to_install.append('wheel')
-        install_wheel(to_install, py_executable, search_dirs)
+        install_wheel(
+            to_install,
+            py_executable,
+            search_dirs,
+            download=download,
+        )
 
     install_activate(home_dir, bin_dir, prompt)
 


Test patch: