diff options
author | Donald Stufft <donald@stufft.io> | 2016-01-19 12:10:28 -0500 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2016-01-19 12:10:28 -0500 |
commit | 65c63eab154d7e837981cb5d9ba916be652d7103 (patch) | |
tree | a4f54aee4060c3e176dbc2bd5c83aa1471485848 | |
parent | deb3f6a58d8fa2a9e40ab286d8eb6d75617462ba (diff) | |
parent | f50df26c44311390351d0a76c79cfc136241ece5 (diff) | |
download | virtualenv-65c63eab154d7e837981cb5d9ba916be652d7103.tar.gz |
Merge pull request #840 from dstufft/download
Try to download the latest versions of preinstalled packages
-rw-r--r-- | docs/changes.rst | 5 | ||||
-rw-r--r-- | docs/reference.rst | 10 | ||||
-rw-r--r-- | docs/userguide.rst | 4 | ||||
-rwxr-xr-x | virtualenv.py | 61 |
4 files changed, 49 insertions, 31 deletions
diff --git a/docs/changes.rst b/docs/changes.rst index 6440899..5a0d51b 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -29,6 +29,11 @@ Release History * Remove use of () in .bat files so ``Program Files (x86)`` works :issue:`35` +* Download new releases of the preinstalled software from PyPI when there are + new releases available. This behavior can be disabled using + ``--no-download``. + + 13.1.2 (2015-08-23) ------------------- diff --git a/docs/reference.rst b/docs/reference.rst index e9b577e..fbc005d 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -90,11 +90,13 @@ Options Provides an alternative prompt prefix for this environment. -.. option:: --never-download +.. option:: --download - DEPRECATED. Retained only for backward compatibility. - This option has no effect. Virtualenv never downloads - pip or setuptools. + Download preinstalled packages from PyPI. + +.. option:: --no-download + + Do not download preinstalled packages from PyPI. .. option:: --no-site-packages diff --git a/docs/userguide.rst b/docs/userguide.rst index 4e552a1..d9ff5aa 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -128,7 +128,7 @@ below. Removing an Environment ~~~~~~~~~~~~~~~~~~~~~~~ -Removing a virtual environment is simply done by deactivating it and deleting the +Removing a virtual environment is simply done by deactivating it and deleting the environment folder with all its contents:: (ENV)$ deactivate @@ -254,5 +254,3 @@ As well as the extra directories, the search order includes: #. The directory where virtualenv.py is located. #. The current directory. -If no satisfactory local distributions are found, virtualenv will -fail. Virtualenv will never download packages. diff --git a/virtualenv.py b/virtualenv.py index 33473b9..9819b1c 100755 --- 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) |