I have two (and more in the future) Python projects that I'd like to package into a global package in order to import its modules and use them in another external projects in the future.

This is how it is structured now:

enter image description here

I made it using git submodule, so I made that Project 1, Project 2, etc. were submodules of the global project.

Now I have a problem, because in Project 1 I use a Python module (a .py file) that I need to use in Project 2 too, and probably in all N projects.

Should I make another git repo that contains all that useful modules to import in other projects, and add to all them as a submodule?


enter image description here

Or can I somehow make that the global project has a library and import the files from there? Here we have a problem, because each project separately will not have the files, so they won't be able to import them

I also was thinking about creating a git repo that has all projects inside, but it wouldn't possible since there are different people working on each project, and they shouldn't be allowed to access to all the repository

  • 1
    Do you really need submodules? They can be problematic. Personally (and this is not to say you don't have got good reasons) I've always found it easier to just have separate repos and then either check them out side-by-side and symlink between them, or package libraries through npm or something like that and have the dependencies installed as opaque third party libraries rather than live code. – zanerock May 9 '18 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.