this is so that packages under src can import from other packages like from otherpackage.helper import .... By experimenting I found that Sourcetrail uses the current PYTHONPATH during scanning, so if only src is in the path then everything is OK, except that references to functions made in the test code are not discovered.
However if test is included as well then any imports like
from mypackage.mymodule import do_thing
anywhere in the codebase fail with
Imported symbol named "mymodule" has not been found.
I think this is because it's ambiguous whether the import refers to src/mypackage or test/mypackage. However the python interpreter itself does not get confused because of the ordering in PYTHONPATH. It would be nice if Sourcetrail could support situations like this as well.
I appreciate that fully qualifying imports or renaming the test packages would work but this would require large changes and may break in the future depending on the behaviour of IDE auto-importing etc.
the codebase I'm working with is structured similarly to this. I've tried to simplify the situation as much as possible:
where
environment
setsPYTHONPATH
like so:this is so that packages under
src
can import from other packages likefrom otherpackage.helper import ...
. By experimenting I found that Sourcetrail uses the currentPYTHONPATH
during scanning, so if onlysrc
is in the path then everything is OK, except that references to functions made in the test code are not discovered. However iftest
is included as well then any imports likeanywhere in the codebase fail with
I think this is because it's ambiguous whether the import refers to
src/mypackage
ortest/mypackage
. However the python interpreter itself does not get confused because of the ordering inPYTHONPATH
. It would be nice if Sourcetrail could support situations like this as well. I appreciate that fully qualifying imports or renaming the test packages would work but this would require large changes and may break in the future depending on the behaviour of IDE auto-importing etc.