5

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?

0

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Why not in this case?
@david The directory can include files generated specifically for the current system, which may have hard coded paths or linked libraries that won't work on other systems. It isn't meant to be portable. Instead, you should include some way of specifying information about the dependencies necessary in the virtualenv, either as a package specification or requirements file, because they are designed to be portable. (However, honestly, if you're just using source control for a project you're working on independently on a single system, including the env could be convenient.)
@JeremyBanks I did not even consider files specific to the current system... But it makes sense that a virtual environment for OSX, Linux and Windows would be quite different

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.