J
J
Jolt2019-05-07 13:27:19
Python
Jolt, 2019-05-07 13:27:19

How to properly organize submodules in Git?

Now I am writing a personal project and made some of the modules separate repositories on Github (submodules).
The conditional project has:
project/ main.py - main script
project/module_1_path/ module_1.py - some submodule number times
project/module_2_path/ module_2.py - some submodule number two
project/logger_path/ logger.py - mine logger (also a submodule), which is used in all other modules, and all modules get access to it through This is not very correct in terms of what if I suddenly want to use module_1 in another project
from logger_path import logger
, I will need to clone it, and then remember (or catch an import error) that I also need to clone the logger to the project root.
You can make a submodule logger for each module, but then, for example, in this case, I will no longer have one logger that everyone accesses, but three copies of one repository, and each module will access its own.
So the question is how to be? How can I make it so that in the next project I would simply clone module_1 into the project and he would pull the logger after himself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2019-05-07
@alternativshik

Why not just install packages from the git repository via pip into the project environment with all the dependencies?

T
TyzhSysAdmin, 2019-05-07
@POS_troi

A submodule is a separate and independent entity, it does not drag anything behind it.
Of course, you can smear yourself with submodules, but very soon you will check to rake it all up :)
Also, keep in mind that with this approach. if you break backward compatibility between modules, then when you update, everything that has not received fixes will fall.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question