Do What I Mean

Virtual development environments with Vagrant

Python's virtual environments are a blessing, but as they manage Python dependencies only, they are also limited.

For example, I use sqlite for most of my projects, but in some cases, I need something else, like a more sophisticated SQL database (e.g. MariaDB) or a no-SQL database (e.g. MongoDB). In situations like that, I use Vagrant:

Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.

What this means is that with Vagrant I can specify all my project's dependencies in configuration files and scripts. This keeps my projects nicely separated and allows me to reproduce my project's environment at will (this process is called provisioning). I can even use this provisioning to transfer the project to a different environment (e.g. from development to test) and to other developers.

If you want to get Vagrant up and running, the Getting Started section provides a good introduction. For a more beginner-friendly tutorial, head to Scotch.io instead. If you want to skip all that, just go to the official documentation or to the PyCharm Vagrant page if that's your IDE of choice.

In short, Vagrant is about provisioning a virtual machine with all the assets you need for your project. There are many provisioners to choose from to help you with that, like Ansible, Puppet and Chef. But I prefer vanilla bash provisioning, because I am already familiar with bash and would have to learn any of the other provisioners. In other words, my needs are not complex enough to warrant the time needed to learn a more advanced provisioner. And, to be honest, I found their learning curve rather steep.

To make my life (and maybe yours) a little easier, I wrote some basic scaffolding which is available here.

©2019 otech-nl