How can I synchronize project dependencies between developers?

谁说我不能喝 提交于 2019-12-12 05:48:20

问题


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:

  1. Developer A installs a package and writes some code that uses it.
  2. He/she pushes the code to the central repo.
  3. Developer B pulls the code and starts working.
  4. 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?


回答1:


I would use virtualenv and create a requirements file

pip freeze > requirements.txt

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

pip install -r requirements.txt

I think this is the most logical approach and is one my team has used multiple times.



来源:https://stackoverflow.com/questions/34344874/how-can-i-synchronize-project-dependencies-between-developers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!