I'm looking for a way to emulate symlinks for Python imports. I'd like to be able to unzip the following folder structure in-place without duplicating files:
root
├─ python_lib
│ └─ my_utils
│ ├─ __init__.py
│ └─ etc.py
├─ app1
├─ app2
└─ app3
├─ lib
│ ├─ __init__.py
│ └─ my_utils.py
└─ run.py
app3/run.py
contains this:
from lib.my_utils import etc
etc.pancakes()
I'd like the code to use the etc
located in python_lib/my_utils/
. Is there anything I can put in app3/lib/my_utils.py
so that Python >= 3.1 will transparently import the python_lib/my_utils/
folder (using relative paths and ..
), and subpackages will also work?