Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv in source control

Perhaps this is more an opinion-based question, but I was wondering whether the contents of a virtualenv should be included in a GitHub repository. Why should it or should it not be included?

like image 961
David542 Avatar asked May 10 '15 20:05

David542


People also ask

What is the purpose of virtualenv?

virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.

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 I put venv 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

No, anything that can be generated should not be included.

Dependencies should be managed with something like pip, and the requirements.txt file can be included.

The only files under source control should be files you absolutely need to get you development environment going. So it can included boot strapping of some sort, ie, you can script the creation of the virtual environment, and that would be the first thing you run once you have cloned.

Also consider that your virtual environment contain binary files. You absolutely do not want those in your repository.

As pointed out by @JeremyBank below, your virtual environment can also differ from system to system meaning that your virtual environment will not be portable.

like image 99
Leon Avatar answered Oct 09 '22 21:10

Leon