python-tools.sh: Make __init__py recognize multiple package modules

import my.mod.thing, my.mod.thang wouldn't work, if the modules where not in
the same directory hierarchy, e.g. in $(HOME)/blah/my/mod/thing.py and
$(HOME)/blub/my/mod/thang.py, not even with PYTHONPATH=$(HOME)/blah:$(HOME)/blub.

This commit fixes that.

See https://stackoverflow.com/questions/1675734

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2020-04-05 12:51:11 +00:00
commit 7fb117a4c4

View file

@ -25,6 +25,8 @@ cmd_create_init()
local e f files base extracted module_path
local del="-------------------------- generated by $myname"
echo "# >> $del >>"
echo "from pkgutil import extend_path"
echo "__path__ = extend_path(__path__, __name__)"
files="$*"
for f in $files; do
test -d $f && continue