On 2020-03-22 16:04:59 +0100, Antoon Pardon wrote:
> $ /opt/csw/bin/python
> Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.

Hmm. Solaris

> As you can see the import works in the second session because I
> had done the needed assignments and exports in bash.
> 
> Now I was wondering, if I could do those kind of preparations in python.
> I would like to start python from an unprepared bash, and do the necessary
> stuff to make the import work.
> 
> I already tried changing os.environ and using os.putenv, but that didn't
> seem to work.

I remember that once upon a time setting LD_LIBRARY_PATH had no effect
on the process itself (only on child processes) on 64 bit Linux, because
the runtime saved that value before loading the first shared library.
Maybe Solaris does the same?

In this case it might help to reexec the program. Something like

    if "ORACLE_HOME" not in os.environ:
        # Need to set env and reexec
        os.environ["ORACLE_HOME"] = ...
        os.environ["LD_LIBRARY_PATH"] = ...
        ...

        os.execv(sys.argv[0], sys.argv)

    # real content starts here

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to