On vient de perdre le serveur, t’as vérifié les sauvegardes récemment ? ooooooooups

april, debian-fr, planet-libre, python

Suivez-moi aussi sur Identi.ca  ou Twitter  ou Diaspora*diaspora-banner

Le titre évoque une situation malheureusement bien connue des sysadmins.

joiesdusysadmin

illustration tirée du site lesjoiesdusysadmin.fr (cliquer sur l’image)

Pour éviter cette situation, Backup Checker est un programme en ligne de commande codé en Python permettant le contrôle automatisé de l’intégrité d’archives (tar, gz, bzip2, lzma, zip) et de la cohérence des fichiers à l’intérieur des archives.

github-logo

Backup Checker est hébergé sur GitHub

Cette version 1.2 apporte le support des tubes Unix, permettant à l’aide des habituels outils comme la commande ssh ou wget de vérifier à distance vos archives tar.{gz,bz2,xz}.

Quelques exemples

Contrôler l’état d’une archive distante hébergé sur un serveur FTP devient aussi simple qu’exécuter la commande suivante :

$ wget --quiet -O - ftp://user:pass@server/backup.tar.gz | ./backupchecker.py -c .

Le même exemple pour une archive accessible en SSH :

$ ssh -q server "cat /tmp/backup.tar.gz" | ./backupchecker.py -c . -

Désormais très simple à mettre en place dans vos scripts, Backup Checker propose également de nombreuses options en ligne de commandes pour bien s’intégrer à votre workflow.

Le projet Backup Checker

Quelques détails sur l’infrastructure du projet. Backup Checker est hébergé sur GitHub (étoiles bienvenues ;) ) et effectue une partie de son intégration continue (110+ tests unitaires) sur travis-ci.

travis-ci

Viennent s’y ajouter plus de 300 tests fonctionnels et des tests sur des archives lourdes et complexes. Le projet essaie ainsi de fournir un livrable de qualité avec une documentation tentant d’être claire sur readthedocs.

readthedocs

Et nous sommes bien sûr à votre écoute si vous identifiez un problème quelconque. De plus nous sommes fans de toutes vos réactions concernant le projet Backup Checker. N’hésitez pas à vous manifester dans les commentaires de ce billet, via le gestionnaire de rapports de bugs ou directement auprès de l’auteur.

Backup Checker 1.2 : verify remote backups

debian, sysadmin

Follow me on Identi.ca  or Twitter  or Diaspora*diaspora-banner

Backup Checker is a command line software developed in Python 3.4, allowing users to verify the integrity of archives (tar,gz,bz2,lzma,zip,tree of files) and the state of the files inside an archive in order to find corruptions or intentional of accidental changes of states or removal of files inside an archive.

The major feature of this new version is the ability of Backup Checker to use Unix streams. Using classic Unix tools like OpenSSH or wget, Backup Check is able to verify a remote tar.{gz,bz2,xz} archive. The following example verifies a tar.gz archive located on remote server through SSH:

$ ssh -q server "cat /tmp/backup.tar.gz" | ./backupchecker.py -c . -

Another short example with the FTP protocol, to verify a tar.bz2 archive located on a remote server through FTP:

$ wget --quiet -O - ftp://user:pass@server/backup.tar.gz | ./backupchecker.py -c . -

Moreover in this release, a new option –configuration-name allows the user to define a custome name for the files generated by Backup Checker (default is defined from the name of the archive using the -g or -G options).

It is a major step for Backup Checker. It is indeed easier and easier to use Backup Checker in your own scripts, allowing to fully automate your backup controls.

Several companies now use Backup Checker to secure their backups. Let us know if we can help you.

As usual, any feedback is welcome, through bug reports, emails of the author or comments on this blog.

Backup Checker 1.0, the fully automated backup checker

debian, python, sysadmin

Follow me on Identi.ca  or Twitter  or Diaspora*diaspora-banner

Backup Checker is the new name of the Brebis project.

Backup Checker is a CLI software developed in Python 3.4, allowing users to verify the integrity of archives (tar,gz,bz2,lzma,zip,tree of files) and the state of the files inside an archive in order to find corruptions or intentional of accidental changes of states or removal of files inside an archive.

Brebis version 0.9 was downloaded 1092 times. In order to keep the project growing, several steps were adopted recently:

  • Brebis was renamed Backup Checker, the last one being more explicit.
  • Mercurial ,the distributed version control system of the project, was replaced by Git.
  • The project switched from a self hosted old Redmine to GitHub. Here is the GitHub project page.

This new version 1.0 does not only provide project changes. Starting from 1.0, Backup Checker now verifies the owner name and the owner group name of a file inside an archive, enforcing the possible checks for both an archive and a tree of files.

Moreover, the recent version 0.10 of Brebis published 9 days ago provided the following features

  • The default behaviour calculated the hash sums of every files in the archive or the tree of files, this was discontinued because of poor performances while using Backup Checker on archives of large size.
  • You can force the old behaviour by using the new –hashes option.
  • The new –exceptions-file option allows the user to provide a list of files inside the archive in order to compute their hash sums.
  • The documentation of the project is now available on Readthedocs.

As usual, any feedback is welcome, through bug reports, emails of the author or comments on this blog.

Le Journal Du Pirate, nouveau média propulsé par un Logiciel Libre qui trouve sa place

april, debian-fr, planet-libre, python

Suivez-moi aussi sur Identi.ca  ou Twitter  ou Diaspora*diaspora-banner

Un peu plus d’une semaine après le lancement en grande pompe du Journal du Pirate, site d’infos participatif francophone inspiré de son grand frère américain Hacker News, nous revenons sur le parcours de ce nouveau média propulsé par un Logiciel Libre.

jdp

Quelques statistiques intéressantes à nos yeux ont été publiées de nouveau dans un journal sur LinuxFr.org, afin de faire un retour quelques jours après ledit lancement.

Pourquoi un Logiciel Libre pour propulser ce site ?

La question peut paraître saugrenue aux aficionados du Logiciel libre qui vont lire ce billet, mais d’autres tentent régulièrement de lancer ce type de site en faisant un moteur à leur sauce, en général privateur. Ça n’est pas l’idée derrière le JdP. Nous voulions un moteur en accord avec notre vision du logiciel avec une interface suffisamment peu envahissante pour apparaître épurée d’un contenu superflu.

github-logo

Keep it simple, stupid

Le principe de ce site est simple, très simple. Une fois identifié ce qu’on veut faire exactement, cela peut paraître plus facile de tout re-coder. Mais c’est à mon sens une erreur dans la plupart des cas. De très bon prédécesseurs existent et ont subi tous les plâtres possibles et inimaginables. Rendons leur justice en utilisant ce qu’ils ont eu tant de mal à mettre au point et contribuons en retour. Pour le Journal du Pirate nous avons opté pour le moteur du site web Lobste.rs , sous licence BSD, qui a une approche mettant en avant la transparence des actions et des utilisateurs du site, attitude qui nous plaît beaucoup.

lobsters

Le site d’actualité Lobste.rs

Sur cette pierre je bâtirai…

Lorsque les fondations sont solides, on construit mieux et du durable. Au lieu de nous consacrer au moteur, l’équipe du Journal du Pirate se consacre au contenu et cherche à proposer la meilleure qualité d’articles possible ainsi qu’à coller à l’actualité. En espérant que cela vous plaise :)

Un média pour et par la communauté francophone

Il nous tient à cœur de présenter ce que produit la communauté francophone. Notre approche est complémentaire de LinuxFR ou des sites traditionnels proposant un vrai contenu éditorial original.

linuxfr_noel

LinuxFR.org, principal site du Logiciel Libre francophone

Nous optons pour présenter un maximum d’infos différentes à nos contributeurs qui effectuent un tri par leurs votes pour permettre aux meilleurs liens d’apparaître en première page. Ce modèle est éprouvé et marche plutôt bien.

Au-delà du Logiciel Libre, nous nous intéressons également aux publications scientifiques francophones et aux tissus des startups françaises, grandes utilisatrices du Logiciel Libre et proposant souvent des défis techniques intéressants.

Rejoignez-nous en réclament votre invitation pour aider à ce choix vous aussi, afin de mettre en avant vos logiciels libres, vos publications scientifiques ou vos startups !

Et vous ? Que pensez-vous de ce nouveau média francophone ? N’hésitez pas à réagir dans les commentaires ou à y demander votre invitation (en laissant votre e-mail dans le champ dédié).

Suivre les stats de son site web en Ruby On Rails avec Piwik

april, debian-fr, planet-cullt, planet-libre

Suivez-moi aussi sur Identi.ca  ou Twitter  ou Diaspora*diaspora-banner

Après avoir lancé Le Journal du Pirate, le Hacker News francophone, j’avais évidemment besoin de suivre la fréquentation du site. J’avais utilisé AWStats sur un précédent projet et je voulais tenter d’utiliser un logiciel de comception un peu plus récente cette fois-ci.

awstats-logo

Piwik semblait convenir parfaitement. Multi-sites, Interface graphique moderne, des bons échos dans la communauté, je me suis donc naturellement dirigé vers cette solution. Piwik se présente comme une application web avec une base de données MySQL derrière.

piwik_app

Pour les gens intéressés, le site officiel propose une démo très sympa permettant de voir tout de suite les points forts de Piwik.

piwik

Le Journal du Pirate est quant à lui une application Ruby On Rails. Or Piwik requiert l’ajout d’un javascript sur les pages que l’on veut surveiller. Ce qui peut s’avérer délicat à réaliser lorsque que l’on maîtrise mal RoR.

La documentation officielle suivante explique très bien la marche à suivre. Ajouter une gem Ruby à son Gemfile, relancer bundle puis quelques éléments de configuration dans le fichier config/piwik.yml et le tout a marché directement.

rails

Je suis très content du résultat. Niveau interface graphique c’est très agréable et Piwik propose un très grand nombre de métriques associées aux différents sites web supervisés. J’en ai profité pour lui faire surveiller ce blog et le site web de MyTux, ma société d’infogérance de serveurs Debian.

Et vous ? Quel est votre ressenti après avoir utilisé quelques temps Piwik ? Des difficultés à le mettre en place avec RoR ? N’hésitez pas à réagir dans les commentaires de ce billet.

Site comme Hacker News en français : Le Journal Du Pirate

april, debian-fr, planet-cullt, planet-libre, python

Suivez-moi aussi sur Identi.ca  ou Twitter  ou Diaspora*diaspora-banner

Avant tout l’adresse du site : Le Journal Du Pirate https://infos.mytux.fr

Un site web comme Hacker News mais francophone propulsé par un Logiciel Libre, je trouve que ça manquait à la communauté francophone.

ycombinator-logo

C’est maintenant chose faite avec un site dérivé du moteur de Lobste.rs. Les sources sont disponibles sur ce GitHub.

github-logo

L’inscription fonctionne par cooptation pour limiter les articles indésirables.

Un petit commentaire avec votre e-mail dans le champ des e-mails et je vous fais parvenir une invitation, qui vous permet à votre tour d’inviter autant de personnes que vous le souhaitez.

Vous pouvez aussi réclamer une invitation depuis le site. L’un des utilisateurs courants vous enverra alors une invitation.

Et tous les commentaires sont les bienvenues bien sûr ;)

Send the same short message on Twitter, Pump.io, Diaspora*… and a lot more

debian, planet-cullt, sysadmin

Follow me on Identi.ca  or Twitter  or Diaspora*diaspora-banner

This is a feedback about installing a self hosted instance of Friendica on a Debian server (Jessie). If you’re not interested in why I use Friendica, just go to « Prerequisite for Friendica » section below.

Frustration about social networks

Being a huge user of short messages, I was quite frustated to spend so much time on my Twitter account. To be quite honest, there is no much I like about this social network, except the huge population of people being potentially interested in what I write.

twitter-logo

I also have been using Identi.ca (now powered by Pump.io) for a while. But I tried for a while to manage both networks Pump.io and Twitter by hand and it was quite painful. And something was telling me another social network was going to appear from nowhere one of these days and I’ll be just horrible to try to keep it up this way.

identica-logo

So I was looking for a « scalable » solution not asking too much personal investment. Subscribing to Diaspora* some days ago on the Framasphere pod, tintouli told me to try Friendica.

Hmmm, what’s Friendica ?

f-intro

Friendica is a content manager you can plug on almost anything: social networks (Facebook, Twitter, Pump.io, Diaspora*,…), but also WordPress, XMPP, emails… I’m in fact just discovering the power of this tool but to plug it on my different social network accounts was quite a good use case for me. And I guess if you’re still reading, for you too.

I tried to use some shared public servers but I was not quite happy with the result, one connector was still missing or public servers were really unstable. So I’m at last self hosting my Friendica. Here is how.

Prerequisite for Friendica

You need to install the following packages:

# apt-get install apache2 libapache2-mod-php5 php5 php5-curl php5-gd php5-mysql mysql-server git

Having a already self-modified /etc/php5/apache2/php.ini, I encountered a small issue with libCurl and had to manually add the following line in the php.ini:

extension=curl.so

Setting up MySQL

Connect to MySQL and create an empty database with a dedicated user:

# mysql -u root -pV3rYS3cr3t -e « create database friendica; GRANT ALL PRIVILEGES ON friendica.* TO friendica@localhost IDENTIFIED BY ‘R3AlLyH4rdT0Gu3ss' »

mysql

Setting up Apache

My server hosts several services, so I use a subdomain friendica.mydomain.com. If you use a subdomain, of course check you do have declared this subdomain in your DNS zone.

apache-logo

I use SSL encryption with a wildcard certificate for all my subdomains. My Friendica data are stored in /var/www/friendica. Here is my virtual host configuration for Friendica stored in the file /etc/apache2/sites-available/friendicassl.conf :

<VirtualHost *:443>
ServerName friendica.mydomain.com
DocumentRoot /var/www/friendica/
DirectoryIndex index.php index.html
ErrorLog /var/log/apache2/friendica-error-ssl.log
TransferLog /var/log/apache2/friendica-access-ssl.log

SSLEngine on
SSLCertificateFile /etc/ssl/certs/mydomain/mydomain.com.crt
SSLCertificateKeyFile /etc/ssl/private/mydomain.com.key
SSLVerifyClient None

<Directory /var/www/friendica/>
AllowOverride All
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

After writing the configuration file, just launch the following commands and it should be good for the Apache configuration:

# a2ensite friendicassl && /etc/init.d/apache2 reload

friendica-trust

Setting up Friendica

Get the master zip file of Friendica, copy it on your server and decompress it. Something like :

# cd /var/www/ && wget https://github.com/friendica/friendica/archive/master.zip && unzip master.zip && mv friendica-master friendica

You need to give www-data (Apache user) the rights to write in /var/www/friendica/view/smarty3/ :

# chown -R www-data:www-data /var/www/friendica/view/smarty3 && chmod -R ug+w var/www/friendica/view/smarty3

Ok, I guess we’re all set, lets launch the installation process! Using your web browser, connect to friendica.mydomain.com. First step you’ll see the installation window which checks the prerequisite before installing. Complete if something is missing.

friendica-installation

First window of the Friendica installation process

Second step asks the host/user/password of the database, complete and the installation process starts. Hopefully all goes just fine.

Next you’ll have to create a /var/www/friendica/.htconfig.php with the content that the last page of the installation process provides. Just copy/paste, check the rights of this file and now you can connect again to see the register page of friendica at the url https://friendlica.mydomain.com/register . Pretty cool!

Register a user

That’s a fairly easy step. You just need to check before that your server is able to send emails, because the password is going to be sent to you by email. If it is ok, you should now identify on the welcome page of friendica and access your account. That’s a huge step to broadcast your short messages everywhere, but we have some last steps before being able to send your short messages on all the social networks we need.

A small break, create an app for twitter on apps.twitter.com

To send your short messages to Twitter, you need to create an app on apps.twitter.com. Just check you’re logged in Twitter and connect to apps.twitter.com. Create an app called with a unique name (apparently), then go to the Keys and Access tokens page, note the consumer key and the consumer secret. You’ll later need the name of the app, the consumer key and the consumer secret.

friendica-decentralized-network

Install and configure the addons

Friendica uses an addon system in order to plug on the different third-parties it needs. We are going to configure Twitter, Pump.io and the Diaspora* plug. Let’s go back to our server and launches some commands:

# cd /tmp && git clone https://github.com/friendica/friendica-addons.git && cd friendica-addons

# tar xvf twitter.tgz -C /var/www/friendica/addon

# tar xvf pumpio.tgz -C /var/www/friendica/addon

# cp -a diaspora /var/www/friendica/addon

You need to modify your /var/www/friendica/.htconfig.php file and add the following content at the end:

// names of your addons, separated by a comma

$a->config[‘system’][‘addon’] = ‘pumpio, twitter, diaspora';

// your Twitter consumer key
$a->config[‘twitter’][‘consumerkey’] = ‘P4Jl2Pe4j7Lj91eIn0AR8vIl2′;

// your Twitter consumer secret
$a->config[‘twitter’][‘consumersecret’] = ‘1DnVkllPik9Ua8jW4fncxwtXZJbs9iFfI5epFzmeI8VxM9pqP1′;

// you Twitter app name

$a->config[‘twitter’][‘application_name’] = « whatever-twitter »;

banner_friendica

Connect again to Friendica. Go to settings => social networks, you will see the options for Twitter, Pump.io and Diaspora*. Complete the requested information for each of them. Important options you should not forget to check are:

Pump.io

  • Enable pump.io Post Plugin
  • Post to pump.io by default
  • Should posts be public?

Twitter

  • Authorize publication on Twitter
  • Post to Twitter by default

Diaspora*

  • Post to Diaspora by default

Done? Now it’s time to send your first broadcasted short message. Yay!

Send a short message to your different social networks

Connect to Friendica, click on the network page, write your short message in the « Share » box. Click on the lock lock, you’ll see the following setup:

friendica-post-default

It means your short messages will be broadcasted to the three networks. Or more, it’s up to you! That’s my setup, feel free to modify. Now close the lock window and send your message. For me it takes some time to appear on Twitter and Diaspora* and it immediatly appears on Identi.ca.

Last words

friendica-stand

Friendica offers to take back the control of your data, by broadcasting content on different media from a single source. While self hosting, you keep your data whatever happends and are not subject to companies losing your data like recently Twitpic. Moreover the philosophy behind Friendica pushed me to dig and test the solution

What about you? How do you proceed to broadcast your short messages? Does Friendica offer a good solution in your opinion? Are you interested in the philosophy behind this project? Feel free to share your thoughs in the comments.

LAST MINUTE: hey, this article is on Hacker News, don’t hesitate to vote for it if you liked it!

Nouveau blog entrepreunarial et entreprise propulsée par Debian

april, planet-cullt

Suivez-moi aussi sur Identi.ca ou sur Twitter 

Un petit billet rapide pour parler de l’activité de la société MyTux, spécialisée dans l’infogérance de serveurs Debian (exclusivement), société dont je suis le fondateur. Mais c’est surtout son blog que je souhaite aujourd’hui vous présenter.

logo-infogerance

Quelques exemples d’articles déjà publiés :

Le blog de la société MyTux se concentre sur l’infogérance de serveurs Debian et vise à informer aussi bien les clients de MyTux qu’un public plus large d’utilisateurs de serveurs Debian.

debian-banner

On y parle donc des bonnes pratiques du domaine, des évolutions des versions stables de Debian, et on y parlera de tout ce qui se rapporte aux serveurs de production sous Debian, vu par des professionnels de l’infogérance.

J’espère vous y croiser bientôt :)

My Debian contributions in January 2014

brebis, contributions-debian, debian

Follow me on Identi.ca  or Twitter 

One of my resolutions for 2014 is to keep trying harder to talk about my Debian contributions. So here it is, on a monthly basis this time I hope, quite short this month because I’m leaving for holidays at the end of the week and I think I won’t have time to contribute more this month.

Debian packages

Below are some packages I updated recently:

1. Brebis, the fully automated backup checker

I successively packaged Brebis, the fully automated backup checker, versions 0.6 to 0.9 (the latter is today in Debian Sid and Jessie) since my last Debian activities blog posts (in french).

brebis-brown-big-logo

Anisette, the mascot of the Brebis Project

2. Pycallgraph, a Python library that creates call graphs for Python programs

Pycallgraph is one of the first Debian packages I have been maintaining. So when I noticed it was upgraded after so much time I was really eager to package the new version 1.0.1. Now available in Debian Sid! Just belown an example of the generated graph for the application Belier, a sysadmin tool.

pycallgraph

3. Belier, the SSH connection generation tool

Nothing really new for Belier, the SSH connection generation tool but I updated the package in order to update the configuration of the Debian package and get rid of some warning messages. Kind of maintenance job I kept avoiding and avoiding, until now.

Bug report

I’d like to take a few seconds to talk about an interesting bug report about the need for a nagios3-dev package I created asking for a new nagios3-dev or nagios3-headers package to offer a simple access to the headers of Nagios for the developers of Nagios external modules.

In Nagios, some headers are generated after the ./configure, meaning it may be platform dependent. I (and not only me, the same request was active already by someone other Nagios module developers) thought it was simple to ask the Nagios3 Debian package maintainer to offer these files in a dedicated package.

It seems until now people just add the missing files in tarball of their app or in their Debian packages, even if these Nagios headers are not really part of this application. In my opinion, that’s why Build-Depends packages are for, don’t you think?

nagios

It seems it is not so simple. I could not understand why it was more important to prevent Debian users who need these files to access these files in a convenient way than letting them to put theses files in there own source tarball/repository. The maintainer told me it could break things. Sure. But we all know an external module of any app often relies on a really specific version of this app. That’s nothing new, thats how external modules work. That’s not every apps in the world which could provide a stable API to ease the development of external modules. But at least they give access to their dev files or headers when they are FOSS. But feel free to explain to me. After all, the bug reports are still not tagged as « won’t fix » ;)

Your turn now :)  I’d be delighted to have your opinions in the comments of this blog post.

Virtual environments with Python 3.3

debian, python, sysadmin

Follow me on Identi.ca  or Twitter 

One of the major features of Python 3.3 is the new venv module, allowing the creation of Python virtual environments on your system.

1. What is a virtual environment?

A virtual environment is a directory dedicated to the execution of your Python applications. Activating your virtual environment will force Python to execute in this directory as the top level of this directory was the root of your file system.

The virtual environments are interesting because of the independence they have toward the host they run on, especially when you want to install several versions of Python or if you want to install lots of dependencies without being the system administrator of the host.

python-logo-master-v3-TM

If you are a Python developer, you must know virtualenv. This really nice application offers a nice way to create Python virtual environment. Moreover it comes with pip already installed in your virtual environment, in order to install other dependencies you need in a really convenience way.

Starting from Python 3.3, the module venv of the Python standard library offers the users to create virtual environments. This new feature will encourage all users to create virtual environments to develop their own Python applications, which is a good practice. Thanks to the experiences of several applications being used in the Python community, the module venv was written to be really efficient and widely available.

The Python Enhancement Proposal 405 (PEP405) offers a really interesting reading if you wish to find more information about this topic.

2. Creating a virtual environment with Python 3.3

With Python 3.3 comes pyvenv-3.3, allowing to create Python virtual environment:

$ pyvenv-3.3 myvirtualenv
$ cd myvirtualenv/
$ tree .
.
├── bin
│   ├── activate
│   ├── pydoc
│   ├── python -> python3.3
│   ├── python3 -> python3.3
│   └── python3.3 -> /usr/bin/python3.3
├── include
├── lib
│   └── python3.3
│       └── site-packages
└── pyvenv.cfg

As we can see, three directories were created.

  • bin/ offers the activate script and different links to the executable python3.3
  • lib/ offers a tree of directories where the libraries and packages you install in your virtual environment will be stored
  • include/ is by default empty
  • pyvenv.cfg offers different configuration options
$ cat pyvenv.cfg 
home = /usr/bin
include-system-site-packages = false
version = 3.3.2

Just before moving on, if you want to use the existing modules in your global site-packages directory on your system, the option –system-site-packages is available.

3. Activate the virtual environment

Lets activate our virtual environment. We need to use the bin/activate file in this environment:

$ source bin/activate 
(myvirtualenv) $

A change in our prompt indicated the good activation of the virtual environment.

4. Installing applications in the virtual environment

But playing around with only the default Python interpreter is not really funny. Lets download pip, the Python installer, but before that we need a dependency setuptools:

(myvirtualenv) $ curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -o ez_setup.py
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
 100 11356 100 11356 0 0 18507 0 --:--:-- --:--:-- --:--:-- 18495
(myvirtualenv) $ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py -o get-pip.py
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
 100 543k 100 543k 0 0 685k 0 --:--:-- --:--:-- --:--:-- 685k

Now lets install Setuptools and Pip:

(myvirtualenv) $ python3.3 ez_setup.py
 Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
 Extracting in /tmp/tmpxlrv7q
 Now working in /tmp/tmpxlrv7q/setuptools-2.0
 Installing Setuptools
... (lots of lines)...
Installed /tmp/myvirtualenv/lib/python3.3/site-packages/setuptools-2.0-py3.3.egg
 Processing dependencies for setuptools==2.0
 Finished processing dependencies for setuptools==2.0
(myvirtualenv) $ python3.3 get-pip.py
 Downloading/unpacking pip
 Downloading pip-1.4.1.tar.gz (445kB): 445kB downloaded
 Running setup.py egg_info for package pip
 ... (lots of lines)...
 Successfully installed pip
 Cleaning up...

Ok now we’re ready to use pip to install anything we need in our virtual environment. Lets think one more second about what we did: we install the Setuptools and the Pip application inside our virtual environment, with nothing written on our main system. Now lets try to install Brebis, the fully automated backup checker, and run it in this environment:

(myvirtualenv) $ pip-3.3 install brebis
 Downloading/unpacking brebis
 Downloading brebis-0.8.tar.gz
 Running setup.py egg_info for package brebis
Installing collected packages: brebis
 Running setup.py install for brebis
 changing mode of build/scripts-3.3/brebis from 644 to 755
changing mode of /tmp/myvirtualenv/bin/brebis to 755
 Successfully installed brebis
 Cleaning up...

We’re now ready to launch Brebis, executing in our virtual environment:

(myvirtualenv) $ brebis -h
usage: brebis [-h] [-c DIR] [-C DIR] [-d DELIMITER] [-g] [-G] [-l FILE]
 [-L DIR] [-O DIR] [-v] 
Fully automated backup checker
positional arguments:
 archives archives to check
optional arguments:
 -h, --help show this help message and exit
 -c DIR, --configpath DIR
 the path to the configurations
 -C DIR, --output-conf-dir DIR
 the directory to store the configuration file
 -d DELIMITER, --delimiter DELIMITER
 delimiter of the fields for the list of files
 -g, --gen-list generate a list of files inside a backup
 -G, --gen-full generate the configuration file and the list of files
 for the backup
 -l FILE, --log FILE the log file
 -L DIR, --output-list-dir DIR
 the directory to store the list of files inside an
 archive or tree
 -O DIR, --output-list-and-conf-dir DIR
 the directory to store the configuration file and the
 list of files inside an archive or tree
 -v, --version print the version of this program and exit
For more information: http://www.brebisproject.org

So we get an execution of the Brebis application inside our virtual environment, installed from our virtual environment with tools installed only in the virtual environment.

That’s a big step that such a feature is now included in the standard library. In the future, you will enjoy the possibility to create new virtual environments for each Python version right out of the box. Moreover, using the –upgrade option of the pyvenv command, you will upgrade, if needed, your virtual environment in a really easy and straightforward way, making environments adaptable in time.

What about you? What do you think about the Python 3 virtual environments and their features, given your own needs? Feel free to use the comments section of this post.