My team is starting a new Python project. We will be using Git with a central repository. Each developer will work on a local virtualenv, and push/pull from the central repo to the local one.
Using this setting, here is a possible scenario:
- Developer A installs a package and writes some code that uses it.
- He/she pushes the code to the central repo.
- Developer B pulls the code and starts working.
- Developer B runs the project locally and gets an ImportError, because he/she hadn't installed the new dependency introduced by Developer A.
My question is: how can I synchronize the project dependencies between all developers?
An approach I considered:
Before any git push
, the developer performs git freeze > requirements.txt
. The file is pushed along with the code.
After any git pull
, the developer performs git install -r requirements.txt
.
Is this approach vaiable? Is it recommended? Are there better approaches?
I would use virtualenv and create a requirements file
that you add to your git repo, every time a new package is needed, it should be added to the requirements file. When a developer pulls they can run
I think this is the most logical approach and is one my team has used multiple times.