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?
2 Answers
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.
-
1virtualenv-tools seems not to be maintained anymore. If you are using python3 probably you'll need to use virtualenv-tools3– IctusAug 23, 2020 at 3:02
That is exactly what docker does.
fpm is good enough for packing the python instance and its third-party libraries. But if you want more customization like environment variables, it can't suit everything.
-
1docker is absolutely great and you could surely ship a virtualenv with your dockerized application. In fact that would be best practice. But docker is not really a packaging system and it cannot be used in every case. So, this is not really answering my question.– brejocJan 2, 2015 at 11:17