Issue
I am wondering whether having an (untracked) virtual environment folder inside of your local Git clone is considered bad directory structure.
It seems cleaner to place the repository and the virtual environment in a single folder, but that is also more awkward and bulky.
Here are the two options I am considering:
A.
git_clone/
virtual-environment/
B.
name_of_project/
git_clone/
virtual-environment/
This question is similar to this one, but for users/contributors instead of maintainers.
Is it bad to have my virtualenv directory inside my git repository?
Solution
To decide, I answer the question "will I reuse my virtual env in multiple projects?" If yes, then I place the virtual env outside the working tree. If no, then I place the virtual env inside the working tree.
As for reuse, projects often do not depend on the same set of libraries. Even when they do depend on the same set of libraries, projects depend on specific versions of libraries. So, having dedicated virtual env inside working tree is a simple way to avoid issues due to incorrect or extraneous dependencies in above situations.
In terms of cost, while dedicated virtual envs can lead to duplicates, most of my virtual envs are in the order of few 10s of MBs; a small price in terms of space to avoid the hassles due to incorrect dependencies. If extra space is indeed an issue, then virtual envs can be created, used, and deleted as and when required given how easy it is to create virtual envs (e.g., via pip and requirements.txt).
Answered By - Venkatesh-Prasad Ranganath Answer Checked By - Terry (WPSolving Volunteer)