I've created a program with two stand-alone components (app1 and app2 below), that are both stand-alone but share a couple of basic modules (stored in app1). I'm now trying to merge these two apps together into one application. My application has a structure like this:
/root
|-docs
|-config
|-app1
| |-src
| | |-main.py
|
|-tests
| |-a_tests.py
|-app2
| |-API
| |-web-server.py
| | |-REST.py
I have a few requirements:
- /app2/API/REST.py and its kin needs to be able to read modules from /app1/src/
- /tests/ needs to be able to read modules from both app1 and app2. The tests are currently all written for /app1/, but I've since moved app1 into a directory deeper and thus they've all stopped working.
I know I may need to use some __init__.py
files (/root/ and all the directories with python files in have an empty one presently) and I've tried __path__
too, but I keep getting ImportError: No module named <main.py>
errors.
I note this question - Relative import in Python 3 not working - and when I try to use a relative import from app2 to app1, I get that error message. But that question only says I need to use absolute imports, not how to do them.
How do I accomplish this?