SK píše v Út 09. 10. 2012 v 20:16 -0700:
>
> I do not understand why you believe that execv should inherit the
> os.environ as its environment: it should, but in PyInstaller 2.0 it
> doesn't. If this isn't clear please let me know and I'll try again.
I'm sorry, my bad. I didn't realize that LD_LIBRARY_PATH is not
overriden.
PyInstaller 2.0 is working properly. There was a bug in 1.5, that was
fixed in 2.0. The motivation was to allow running apps created by
pyinstaller from another app created by pyinstaller.
Let me explain how pyinstaller works:
- frozen app is run as two processes
1st sets up environment (overrides LD_LIBRARY_PATH etc.)
2nd runs python code
- when you use execv or similar, you are running 1st process
that again overrides LD_LIBRARY_PATH. And then 2nd process is
started again.
What you probably need is to start just the 2nd process again. It won't
work this way. You should try different approach. Probably os.for()
could do what you need:
-----------
import os, sys
my_lib_path = '/path/to/my/lib'
ld_lib_path = os.environ.get('LD_LIBRARY_PATH')
print '\nBefore:', ld_lib_path
if ld_lib_path is None:
os.environ[ 'LD_LIBRARY_PATH' ] = my_lib_path
print 'Forking...'
elif my_lib_path not in os.environ[ 'LD_LIBRARY_PATH' ]:
os.environ[ 'LD_LIBRARY_PATH' ] += os.pathsep + my_lib_path
print 'Forking...'
pid = os.fork()
if pid:
# Wait for child process.
os.waitpid(pid, 0)
else:
# Child code.