I want to create one virtualenv using another as the starting point, is this possible?
I have to use cases in mind:
-
Let’s say I have a two
virtualenvone for production and one for development. The development environment requires the same packages as the production environment, but it requires others I don’t want in the production environment. I don’t want to install the common packages twice. -
I want to experiment with a development version of a package, say
matplotlibfor example. The development version of the package has the same requirements as the stable version. So I create avirtualenvcalledmatplotib_stableand install the requirements and the stable version. Then I create a secondvirtualenvcalledmatplotlib_devand usematplotlib_stableas a starting point (for thematplotlibrequirements) but then I install the development version.
How do I install from a local cache with pip? seems to address the issue of downloading packages, but I don’t think it deals with modifying sys.path.
One solution is to use
virtualenvwrapper‘sadd2virtualenvcommand. ThisSo if I have two
virtualenv,ENV1andENV2, and I wantENV2to access the packages inENV1, then I need to:activate
ENV2:workon ENV2add
ENV1‘s site-packages directory usingadd2virtualenv:add2virtualenv $WORKON_HOME/ENV1/lib/python2.6/site-packagesThe above assumes
$WORKON_HOMEis the location of your virtualenv directories, and that you are using python2.6, so obviously adjust those accordingly.While this provides access to the packages it does not adjust the shell path. In other words, scripts installed to the
bindirectory are not accessible using this method.