How do I control the version of pip
which is used in a freshly created venv
?
By default, it uses a vendored pip distribution which may be out of date or unsuitable for whatever other reason. I want to be able to create a venv
with a user-specified version of pip installed initially, as opposed to creating one and then upgrading the pip installation from within the env.
From reading the source of virtualenv, it looks like pip is installed from a source tarfile included with virtualenv. In virtualenv 1.10.1, it is pip-1.4.1.tar.gz
in the site-packages/virtualenv_support
directory (it gets setuptools
from the same place). You could feasibly replace that archive to control the version; virtualenv.py, at least the version I have, doesn't care which version of pip is there:
if not no_pip:
install_sdist('Pip', 'pip-*.tar.gz', py_executable, search_dirs)
You could also pass the --no-pip
option and then install the version you want from source.
In virtualenv 1.11, it looks for a wheel file (e.g. pip-*.whl
) instead of a tar.gz
, but other than that it acts the same way (thanks @wim for the update).