Search code examples
pythongitoopvirtualenvpypi

Common libraries in many projects


I have few projects and they use some common code. I refactored this code into common library but then a problem arose. How to manage this common code. I've considered some options which are:

  1. libraries as soft links in filesystem.
  2. libraries as git submodules.
  3. dependencies managed with pip/requirements.txt.

What are pros and cons of this solutions? Do you have another proposals? Which one should i choose and why?

I use Git, and python in virtualenv.


Solution

  • The third option with virtualenv is really convenient. Just make a requirements file in your project, install the dependencies into your virtualenv, and run the env. Each project can have their own dependencies and virtualenv, and nothing overlaps. You also don't have to worry about installing conflicting modules in your system's Python.