Purging the venv using the labs user_env_compile feature with the CLEAN_VIRTUALENV env var doesn't work: since commit 6aadf16 VIRTUALENV_DIRS is unassigned, so nothing gets deleted.
I made the distinction between legacy- and modern-style virtualenvs. You may not want to merge this as-is because it will move legacy-venv from /app to /app/.heroku/venv and the user will have to update PYTHONHOME.
Does bin/release force PYTHONHOME to /app/.heroku/venv/ ? In this case we don't want any legacy venv and this commit is ok.
In fact I had the opposite problem after trying to purge my virtualenv with the purge branch (as documented here: http://stackoverflow.com/a/9463068/343834), the venv was moved to /app from /app/.heroku/venv and it broke my app by not being anymore in PYTHONHOME. If you have access to heroku support requests it's the #54723.
Fix CLEAN_VIRTUALENV usage so it actually works.
Fix old-style virtualenv cleanup with CLEAN_VIRTUALENV.
Also remove old artifacts from cache to avoid restoring
an old-style during the next commit.
This pull request passes (merged a2e7871 into bccec5c).
I added a second commit because we also need to clean CACHE_DIR.
Now this is not ideal because we restored old artifacts from the cache just to have them deleted but I don't wanted to mess up with the code by moving the cleanup block before the cache retrieval. But it works :)
Any movement on this, Kenneth?
There are some drastic changes to this in the pipeline, so I'm holding off for now.