Showing post with tag virtualenv. Show all

vagrant 1

by Malik BOUGACHA, EBU on 14 Sep 2013

Developpement sandboxing

Vagrant is a way to sandbox the devloppement environement. I will take python as an example of sandbox and explain how we come from a simple os based devloppement environement and test to a vm env.


Let's start with a simple machine environement


The being a very simple flask server:

from Flask import Flask 

app = Flask() 

if __name__ == "__main__": 

Great right ?
But what happens if we add more dependencies, for example requests, a python module for doing http request.

from Flask import Flask 
import requests 

app = Flask() 

def main(): 
    return request.get("").json() 

if __name__ == "__main__": 

The example is pretty simple right ? What does happen when we want to deploy it ? It will crash depending on the version of the requests module we have. As we have a stable version of debian, we don't have the right version of the library and of course we don't want to install it at a system wide level But there is a solution for this in python: virtualenv.

dependencies python vagrant virtualenv