Create a Sandboxed Python/ruby Environment

This post describes the configuration we use to have sandboxed environments for projects developped in Ruby or python.
By sandboxed, we mean that for each project (typically hosted in a specific git repository), the set of packages (i.e. ruby gems or python modules) required for the projects are all separated and self-contained - from the system, and from each other.

You can then install all of the required gems from that specified sources:

$> bundle install
$> git add .ruby-* Gemfile Gemfile.lock

The second command adds in particular the Gemfile and Gemfile.lock to your repository.
This ensures that the other developers on your project, as well as your deployment environment, will all use the same third-party code that you are using now.

Sandboxed Python with Pyenv, virtualenv and autoenv.

While I confess I’m not a python lover, I still had to work sometimes with projects written in python (such as Easybuild).
In the attempt to setup a clean and sandboxed ennviroment (similar to the above one mentioned under ruby with RVM and project gemsets), I arrived to the following setup (typically assuming you installed Homebrew if you’re running Mac)

as mentioned above, the equivalent of Gemfile for ruby can be generated using the pip freeze -l command, and a classical convention is to name this file requirements.txt.
It lists all the pip packages used in the virtual environment.

You can then install all pip packages back from the requirements.txt file via:

The second command adds all the required files to your repository. This ensures that the other developers on your project, as well as your deployment environment, will all use the same third-party code that you are using now.