Create a virtualenv from another virtualenv
<p>Can we create a <a href="https://virtualenv.pypa.io/en/stable/" rel="nofollow">virtualenv</a> from an existing virtualenv in order to inherit the installed libraries?</p>

<p>In detail:</p>

<p>I first create a "reference" virtualenv, and add libraries (with versions fixed):</p>

<pre><code>virtualenv ref
source ref/bin/activate
pip install -U pip==8.1.1     # &lt;- I want to fix the version number
pip install -U wheel==0.29.0  # &lt;- I want to fix the version number
</code></pre>

<p>Then:</p>

<pre><code>virtualenv -p ref/bin/python myapp
source myapp/bin/activate
pip list
</code></pre>

<p>I get:</p>

<pre><code>pip (1.4.1)
setuptools (0.9.8)
wsgiref (0.1.2)
</code></pre>

<p>How to get my installed libraries?</p>

<p><strong>Similar question</strong></p>

<p>I saw a similar question: <a href="http://stackoverflow.com/questions/10538675/can-a-virtualenv-inherit-from-another">Can a virtualenv inherit from another?</a>.</p>

<p>But I want a isolated virtualenv which didn't use the referenced virtualenv, except for libraries installation. So, adding the specified directories to the Python path for the currently-active virtualenv, is not the solution.</p>

<p><strong>Why doing that?</strong></p>

<p>Well, we have an integration server which builds the applications (for releases and continuous integration) and we want to keep the control on libraries versions and make the build faster.</p>

<p><strong>Create a relocatable virtualenv</strong></p>

<p>I think I could use a <a href="https://virtualenv.pypa.io/en/stable/userguide/#making-environments-relocatable" rel="nofollow">relocatable virtualenv</a>, that way:</p>

<ol>
<li>create the <strong>ref</strong> virtualenv</li>
<li>make it relocatable: ``virtualenv --relocatable ref```</li>
</ol>

<p>For "myapp":</p>

<ul>
<li>copy <strong>ref</strong> to <strong>myapp</strong></li>
</ul>

<p>What do you think of this solution? Is it reliable for a distribuable release?</p>

<p>when you install the second virtualenv you have to add <code>--system-site-packages</code> flag.</p>

<pre><code>virtualenv -p ref/bin/python myapp --system-site-packages
</code></pre>

python virtualenv