Issue
I am starting my first actual python project. I follow "Learn Python the Hard Way" to make an initial Python skeleton and I am using virtualenv too.
Now I want to use git to do the version control. According to some previous questions in SO, I am not suggested to commit any virtualenv files. Instead, I could use pip freeze > requirements.txt
, and use .gitignore
to ignore the virtualenv directories.
However, both virtualenv and Python project skeleton require a /bin
directory, should I commit it as well? (Actually I don't really know what the role /bin
is playing in Python project)
Any suggestions are appreciated, if there is something wrong with my process to set up a Python project, please correct me.
Solution
yourproject/bin
is distinct from yourproject/env/bin
, where yourproject/env
is the virtual environment's directory (and neither of them is /bin
in the root directory). You should ignore everything in env
, and indeed, your project should work for someone who isn't using a virtual environment, or is managing it differently. Otherwise, you lose the benefits.
Let's imagine for a second that you finish your project, and I want to use it for a new task. I start a new project with a virtualenv of its own, and install some other components I want to use, and then yours. Oops, now I have an older version of Python than I started out with, and that bug in deactivate
from two years ago somehow got resurrected. Imagine debugging that, let alone the annoyance of finding that your project replaced some files of mine.
(As these things go, the bin
directory is a pretty static part of the virtual environment; zapping other parts of my private env
would be much more destructive. If you committed lib
you would have prevented me from installing any other components before yours.)
Answered By - tripleee Answer Checked By - Robin (WPSolving Admin)