vagrant 2


by Malik BOUGACHA, EBU on 03 Oct 2013

virtualenv

introduction

Last time, we discovered a problem inherant to the software world. Software change an d api to the software changes too. We also briefly talked about virtualenv in python. How does it work ?

Simple usage

You can specify a python virtualenv which is a set containing a python interpreter and a set of libraries. You can specify a version of each libary you want either by a specific version number or by a minimum version.
We define this set of libraries at the configuration time. Let's take a simple example :

mkdir mynewproject 
cd mynewproject 
touch pip_requirements.txt 

So now we will switch to the virtualenv

virtualenv . 
source bin/activate 

we can see that we have only a couple dependencies

pip freeze #this will list installed module that pip installed 

so let's add a couple of dependencies. To make it shorter and more easily manageable, we will put everything in the pip_requirements.txt.

http://example.com/baz-0.3.tar.gz #we can also specify a http or ftp tar containing a setup.py 
requests=0.10.0 #yes I love old version 

then we install them in the virtualenvironnement :

pip install -r pip_requirements.txt 

As you can see, this installed the module in the new virtualenv.

pip freeze 
```bash
Now that we installed new dependencies, we will leave the virtualenv. 

deactivate


we can check that we are outside of the virtualenv by doing  

pip freeze ```

python version

Now, imagine that you would like to test

System wide dependencies

Great now we can easily manage

  • python dependencies
  • python interepreter

What if we want to add system dependencies ? Say a mysql database and a memcache cache ? We could also want to test our system on multiple host configuration, some with mysql other with posgre, or even test it under different system, for example a BSD based system and a linux based one. both having their own library version or even software. We have another solution. Instead of a simple virtualenv, we will see how we can simply put all our environnement into a separated environnement.


python vagrant

Comments

  • Malik BOUGACHA

Recent posts



23 May 2016
OSCON 2016
Michael Barroco

15 Jan 2015
Version support
Frans De Jong

03 Jan 2015
Quality Wishes for 2015
Frans De Jong

22 Dec 2014

17 Dec 2014
Responsive QC
Frans De Jong

30 Sep 2014
Open Source Meetup at IBC
Mathias COINCHON

25 Mar 2014
EBU.io - February Update
Michael Barroco

31 Jan 2014
EBU.io - January Update
Michael Barroco