2

I have a python project and wish to include dependencies in a single directory named "deps" as follows:

+deps
---+dep1
---+dep2
+module1
+module2

An import statement would be something like this:

import deps.dep1

My intention is to have "deps" as a submodule in git. Is this the right way to go about it? I've chosen this course as automating deploy of python using virtualenvs is such a pain!

EDIT: If I choose to go this way, I need to add the "deps" directory to PYTHONPATH or use sys.path.append(). I am trying to figure out a solution without modifying all the import statements and without having to place an export PYTHONPATH statement in bash profile(which will again cause issues during deployment) Please help!

semantic_c0d3r
  • 819
  • 2
  • 15
  • 31

2 Answers2

0

There is no right or wrong way about it. Many projects prefer to bundle dependencies to keep tight control and to avoid having to depend on package managers, or the availability of packages on a given system.

I would keep deps itself as part of the main git repository and have each dependency as separate git submodule, which would then be a fork of the respective project's own git/Hg repository.

Alexander Gessler
  • 45,603
  • 7
  • 82
  • 122
0

It is a good way if you want to keep a clear reference to the exact version of each of those deps.

It becomes cumbersome if you have to modify the sources of those deps (in which case, you need to add, commit and push those changes for each deps modified, then go back one level, add and commit the changed gitlink representing the new SHA1 of those submodules in the main repo index)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250