the most common answer to this Question Where do I put my python files in the venv folder? says, that you shouldn't place your own files within the venv directory.
The strongest argument is just not to mix up your own files with foreign files, which is quite weird, because in general developers include a lot of foreign files or code or libraries to not reinvent the wheel. So I think this isn't a real good point.
The other argument is
It provides an isolated environment wherein you can download a different version of python packages and run it for your project. Hence, do not put anything inside your virtual environment. Keep it clean.
I think it is on the contrary the best thing to put your code within the venv:
- I create my venvs with
--copies
, so my venv-dir physically contains all the stuff, which is needed to run my actual project code. A python installation is not that big at all. - The venv contains exactly the packages (be it downloaded, or self-written general packaged code) in exactly the testet applicable version for the actual project code. Which might or might not fit to other project code as well, but this doesn't matter because everything is just there/optimized/installed for this project.
- The whole venv directory is under version control, so i might basically uninstall a package even via subversion instead of pip.
- I could even deploy the whole venv including the project code via svn to another machine (if its "similar enough" of course...) and directly have all i need in one place.
Finally the main argument: My project code will only ever run if the specific venv is loaded, because the general installation doesn't "know" the installed packages within.
So: What is so bad about a source
folder within my venv folder if the project code can't run without it anyway?