Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv and source version control

I recently started a Django project and I quickly realized that virtualenv will be really useful for many reasons. I set up the virtualenv and my project, but now I wonder what file I should add to my source control (in my case, Mercurial). Should I add all the files under the venv folder? How do I make sure a colleague can clone and get started to work immediately withou having to setup the env again?

like image 315
Martin Avatar asked Mar 06 '12 15:03

Martin


People also ask

What is the purpose of virtualenv?

virtualenv is a tool for creating isolated Python environments containing their own copy of python , pip , and their own place to keep libraries installed from PyPI. It's designed to allow you to work on multiple projects with different dependencies at the same time on the same machine.

What is the difference between virtualenv and Virtualenvwrapper?

Virtualenvwrapper is a utility on top of virtualenv that adds a bunch of utilities that allow the environment folders to be created at a single place, instead of spreading around everywhere.

What is source in virtualenv?

Once you create a virtualenv, you will see source created in the directory. You must cd to that particular source and do source activate to start working on that particular virtualenv. Each virtualenv has its own source. You can also use virtualenv wrapper to make things easier.

Should venv be in Gitignore?

You should add it to gitignore file. Then, you should create requirements. txt file and populate it with the packages you have installed. Then, on your production server, create the virtual environment and run pip install -r requirements.


1 Answers

You generate a "requirements" file (usually requirements.txt) that you commit with your project:

pip freeze > requirements.txt 

Then, each developer will set up their own virtualenv and run:

pip install -r requirements.txt 
like image 62
Chris Pratt Avatar answered Sep 27 '22 18:09

Chris Pratt