Python – Packaging a virtualenv

deploymentpackagingpythonvirtualenv

I'd like to package a Python virtualenv with fpm, so that I can deploy it to my servers. I want to setup the virtualenv somewhere in my home directory without having to use root permissions, but deploy to e.g. /opt. virtualenv itself seems to have no destdir option. I know that there is a relocatable option, but it failed for some packages in the past and I don't trust it to work in all cases. Are there any other options, besides setting up a chroot for packaging or actually setting up the virtualenv in my local /opt directory?

Best Answer

Inspired by this build script I've been testing and using virtualenv-tools for serveral month now to relocate virtual environments and never had any problems. It is easily possible to relocate a virtualenv with e.g. virtualenv-tools --update-path /opt/my_project/virtualenv and package it with fpm afterwards.

Related Topic