Virtualenv and version control

I recently started a Django project, and I quickly realized that virtualenv would be really useful for many reasons. I set up virtualenv and my project, but now I am wondering which file I should add to my original control (in my case Mercurial). Should I add all files to venv folder? How can I make sure a colleague can clone and start working immediately when you need to configure env again?

+56
python django mercurial virtualenv
Mar 06 2018-12-12T00:
source share
2 answers

You create a requirements file (usually requirements.txt ) that you complete with your project:

 pip freeze > requirements.txt 

Then each developer will install their own virtualenv and run:

 pip install -r requirements.txt 
+68
Mar 06 2018-12-12T00:
source share

All of these environmental issues are common when you are developing python / django! I went through all these problems and I tested some solutions! Things I tested:

  • The project works locally
  • Running a project in virtualenv
  • Project running on VM
  • The project runs in a virtual machine using a firewall

The best solution I found was # 4! because the company I worked with, each person in the team has a different OS, all types of windows, mac and linux, and it takes time to install all the dependencies for each environment! So we decided to try virtualenv, which is really good! but still, each person must set up his own environment. The problem with virtualenv is that all python sources are in the environment I am creating! Therefore, I would not push these files to the original version control! The best solution was # 4, because that was exactly what I needed, Vagrant uses Chef to set up your environment, so you just need to write some recipes and let the tramp run them for u! Then u click these recipes on SCM, then when the next person gets the files from SCM and reboots the VM, all the dependencies will be automatically installed!

I have a blog post explaining more about the subject, and also I created a Django Blank project on github so that you can get this is the starting point of your project using tramps.

http://arthurnn.com/blog/2011/11/25/easy-django-quickstart/ (the link is no longer active, therefore is associated with the Wayback Machine)

EDIT

The solution from Chris Pratt is also good, but some libraries are not so easy to install on all OSs, for example, many people on Mac get problems when they want to install MySQLdb-python. which is really a shared library, but if everyone in your team needs to spend time solving these problems, this is not very good!

+6
Mar 06 2018-12-12T00:
source share



All Articles