st3fan/b2g-python — pull request #1 by jlebar (2013-01-18 21:42:25+00:00)
Title: Add a |python| wrapper script which sets the right environment variables...

... and invokes /data/python/bin/python.

Crucially, the wrapper script sets LD_PRELOAD=libpython2.7.so. Without
this, we can't load any of the libs in lib-dynload, which means that we
can't import any Python module which uses native code (e.g. the select
module).

Without LD_PRELOAD, we get an error like the following when we try to
import a module which uses native code:

>>> import subprocess
Traceback (most recent call last):
File "", line 1, in
File "/data/python/lib/python2.7/subprocess.py", line 429, in
import select
ImportError: Cannot load library: reloc_library[1285]: 9814 cannot locate 'PyDict_Next'...

The root problem is that the lib-dynload libraries do not have an
explicit dependency on libpython.so (see readelf -d), so therefore the
bionic linker doesn't try to resolve their symbols against libpython.
Setting this dependency would be the Right Fix.