To find out what Python files a Python app (let's say "SpiderOak") accesses, you can use
- Code: Select all
strace -eopen -f ./SpiderOak 2>&1 | grep / | grep -v ENOENT | cut -d "\"" -f 2 | sort | uniq > openedfiles
To find out where Python "eggs" live, and to conveniently move them in place, you can use
- Code: Select all
DIRS=$(find . -name *.egg-info -exec dirname {} \; 2>/dev/null | sort | uniq)
for DIR in $DIRS; do
SRCS=$(find $DIR -mindepth 1 -maxdepth 1 -not -name *egg-info -type d -or -name *.py)
mv $SRCS .
done
Let's not forget .so libraries:
- Code: Select all
mv usr/lib/pyshared/python*/* usr/bin/
Update 1/11: Looks like we should put in Some.AppDir/usr/share/pyshared/sitecustomize.py whenever the AppDir contains .py files:
- Code: Select all
import os.path, sys, glob
appdir = os.path.abspath(os.path.join(__file__, "../../../../"))
sys.path = glob.glob(appdir) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/py*")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/py*/*/")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/dist*/")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/dist*/*/")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/site*/")) + \
glob.glob(os.path.join(appdir, "usr/lib/py*/*/")) + \
glob.glob(os.path.join(appdir, "usr/share/py*/")) + \
sys.path
This gets picked up since AppRun exports Some.AppDir/usr/share/pyshared/ as $PYTHONPATH. It gets executed before the real app is run. Hopefully this does the trick. Needs to be tested though.
