Hi all. I have a locally-built version of Python (2.7.11) that I'm copying around to different systems, running all different versions of GNU/Linux. Because I need this to work across systems I'm bundling important .so's with my Python installation (libcrypto, libssl, libreadline, libgmp) which are dynamically loaded when I do things like "import ssl" etc.
I have a wrapper script around this Python that everyone runs, rather than invoking it directly, and it is able to set some environment variables etc. So, I had been setting LD_LIBRARY_PATH before I invoke Python so it can find the "right" versions of libcrypto.so etc. That works fine, but here's the problem: because LD_LIBRARY_PATH is in Python's environment it is also passed down to programs invoked by Python. That means if I (for example) invoke subprocess.call(['ssh', ...]) then it fails because the system ssh is looking for the system libcrypto.so, and when it finds the Python libcrypto.so instead (because of LD_LIBRARY_PATH) it fails. What I'd like to do is have a way of setting the library path that Python uses when it tries to load .so files (for example in the ssl module which loads lib-dynload/_ssl.so which links to libssl.so and libcrypto.so), WITHOUT setting LD_LIBRARY_PATH in the environment that Python passes to its children. Is there any way to do this? It seems like there must be some way to do it, because if after I start python with LD_LIBRARY_PATH set, then I delete it from os.environ, then I import ssl it works, so it's still set in Python's environment. But I don't want to have to modify all my scripts to unset LD_LIBRARY_PATH, plus that's not the right thing to do in case someone needs to set LD_LIBRARY_PATH for themselves. What I've tried so far is writing a little Python script that unsets LD_LIBRARY_PATH and setting PYTHONSETUP to the name of that script in my wrapper, which does seem to work, but that takes away the ability for users to use PYTHONSETUP themselves which is sub-optimal. Does anyone have any other ideas? -- https://mail.python.org/mailman/listinfo/python-list