Add option to make virtualenv's relocatable
Sometimes, when running tests in virtualenvs in Jenkins, you can get screwed by the fact that PyPI is about as reliable as a drunk cat. So, if your Jenkins virtualenv based system needs to be reliable, having a job that pre-creates the virtualenvs and then archives them so that the real jobs can use the "last good venv" is important. Problem is, to do that right, you have to wind up moving the virtualenvs- which means after creating them, you have to make them relocatable:
virtualenv --relocatable .venv
Then when you unpack your tarball, you have to fix the things that virtualenv --relocatable didn't do (shown here as command line perl - sorry, it's easier to do this way in our script)
perl -MCwd -ple '$CWD=Cwd::abs_path();s,^VIRTUAL_ENV=.,VIRTUAL_ENV="$CWD/.venv",' -i .venv/bin/activate perl -MCwd -ple '$CWD=Cwd::abs_path();s,^/./.venv/src/(.),$CWD/.venv/src/$1,' -i .venv/lib/python2.7/site-packages/easy-install.pth perl -MCwd -ple '$CWD=Cwd::abs_path();s,^/./workspace/.,$CWD,' -i .venv/lib/python2.7/site-packages/.pth
It would be STELLAR if tox just knew how to be resilient in the case of me wanting to tar up an entire .tox dir and drop it elsewhere.
I erroneously filed this against pytest earlier: https://bitbucket.org/hpk42/pytest/issue/107/add-option-to-make-virtualenvs-relocatable for the discussion there.