title: How to get "python -m venv" to directly install latest pip version
body: <p>As part of the compilation step for a new python version, I fetch and run <a href="https://bootstrap.pypa.io/get-pip.py" rel="noreferrer"><code>get-pip.py</code></a>, to have the latest pip installed next to the python executable:</p>
  
  <pre><code>$ /opt/python/3.7.0/bin/python --version
  Python 3.7.0
  $ /opt/python/3.7.0/bin/pip --version
  pip 18.0 from /opt/python/3.7.0/lib/python3.7/site-packages/pip (python 3.7)
  </code></pre>
  
  <p>I have 25 such versions under <code>/opt/python</code>, although I mostly use the five latest versions of each major.minor version that is not EOL. To setup an invironment I used to run <code>virtualenv</code> or my <code>virtualenvutils</code> with the <code>-p /opt/python/X.Y.Z/bin/python</code> option to get a virtual environment with a specific version.</p>
  
  <p>With Python 3.7 this gives the imp module deprecation warning:</p>
  
  <pre><code>$ virtualenv -p /opt/python/3.7.0/bin/python /tmp/py37virtualenv
  Running virtualenv with interpreter /opt/python/3.7.0/bin/python
  Using base prefix '/opt/python/3.7.0'
  /opt/util/virtualenvutils/lib/python3.6/site-packages/virtualenv.py:1041: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp
  New python executable in /tmp/py37virtualenv/bin/python
  Installing setuptools, pip, wheel...done.
  </code></pre>
  
  <p>I have little hope this will be solved in virtualenv, as this has had a <code>PendingDeprecationWarning</code> at least since 2014 (as can be seen from the output in <a href="https://stackoverflow.com/q/26550004/1307905">this question</a>)</p>
  
  <p>While investigating replacing <code>virtualenv</code> with <code>python -m venv</code> in <code>virtualenvutils</code>, I first created a new <code>venv</code> based virtual environment by hand:</p>
  
  <pre><code>$ /opt/python/3.7.0/bin/python -m venv /tmp/py37venv
  $ /tmp/py37venv/bin/pip --version
  pip 10.0.1 from /tmp/py37venv/lib/python3.7/site-packages/pip (python 3.7)
  </code></pre>
  
  <p>That has an old <code>pip</code> version! If you use it, you'll get:</p>
  
  <blockquote>
    <p>You are using pip version 10.0.1, however version 18.0 is available.<br>
    You should consider upgrading via the 'pip install --upgrade pip' command</p>
  </blockquote>
  
  <p>In the virtual environment created with <code>virtualenv</code> you immediately get the latest version:</p>
  
  <pre><code>$ /tmp/py37virtualenv/bin/pip --version
  pip 18.0 from /tmp/py37virtualenv/lib/python3.7/site-packages/pip (python 3.7)
  </code></pre>
  
  <p>I can run a post-creation step:</p>
  
  <pre><code>/tmp/py37venv/bin/pip install -U --disable-pip-version-check pip 
  </code></pre>
  
  <p>which will take extra time. And if there was a some security update for <code>pip</code>, this would imply running the non-secure version to get a secure version, an ideal point of attack.</p>
  
  <p>From <code>virtualenvutils</code> it is trivial to do the multiple steps to create a <code>pip</code>-less virtualenv and then add <code>pip</code> using <code>get-pip.py</code>. From the command-line this is not so simple:</p>
  
  <pre><code>$ /opt/python/3.7.0/bin/python -m venv --without-pip /tmp/py37venvnopip
  $ /tmp/py37venvnopip/bin/python -c "from  urllib.request import urlopen; response = urlopen('https://bootstrap.pypa.io/get-pip'); open('/tmp/tmp_get_pip.py', 'w').write(response.read())"
  $ /opt/python/3.7.0/bin/python /tmp/tmp_get_pip.py
  ......
  $ /opt/python/3.7.0/bin/pip --version
  </code></pre>
  
  <p>pip 18.0 from /opt/python/3.7.0/lib/python3.7/site-packages/pip (python 3.7)</p>
  
  <p>What is causing <code>/opt/python/3.7.0/bin/python -m venv</code> to take that old <code>pip</code> version? Is that the version available when 3.7.0 was released? </p>
  
  <p>How can I update my install under <code>/opt/python/3.7.0</code> in some way so that using <code>/opt/python/3.7.0/bin/python -m venv</code> creates a virtualenv with the latest <code>pip</code> version without reverting to scripts, aliases or using multiple commands? Having the latest <code>pip</code> installed under <code>/opt/python/3.7.0</code> obviously is not enough.</p>
  
  <p>There are two bundled wheels:</p>
  
  <pre><code>/opt/python/3.7.0/lib/python3.7/ensurepip/_bundled/setuptools-39.0.1-py2.py3-none-any.whl
  /opt/python/3.7.0/lib/python3.7/ensurepip/_bundled/pip-10.0.1-py2.py3-none-any.whl
  </code></pre>
  
  <p>I suspect I need to update those. Is there a better way than updating those by hand? Some option for <code>/some/python -m venv</code> would be nice.</p>
  
  <p>(And running <code>/some/python -m ensurepip --upgrade</code> doesn't do the trick)</p>
  
  <hr>
  
  <p>Running the deprecated <code>/opt/python/3.7.0/bin/pyvenv</code> has the same old <code>pip</code> version problem. </p>