I have two projects A and B. B is a git submodule being called in a script called run.py of A. When I run it, fails telling me it can't find some inner module of B (ERROR 1). To solve this I add on top of run.py of A the following:
import sys
sys.path.append("pathToProjectB")
And it works. However does anyone know another way of doing this? Perhaps some better project structure (B has to be a GIT submodule of A, that can't be changed) or some configuration in the virtual environment folder? Is this the only way of making a GIT submodule work within a python project?
UPDATE 1: Moreover if I have some file in B that has the same name as a file in A then python can gets the file of A while I want it to get the file of B (ERROR 2).
UPDATE 2: There is indeed a way of correcting ERROR 1 without having to put :
import sys
sys.path.append("pathToProjectB")
in top of run.py of project A. You do it by installing project B as a package in A and not just having it as a git submodule in your project structure of A: pip install -e ./ProjectB but you have to create a setup.py file in Project B first (and a readme if the setup.py uses it). More info here https://shunsvineyard.info/2019/12/23/using-git-submodule-and-develop-mode-to-manage-python-projects/
I am still having problems with ERROR2... so A and B have a some file called data with some class data. B calls its own data class. However when I call B from A, B call data class from A and not its own...how can I fix this?