py2app/wxpython os.getenv and path not working inside .app

I think the issue here is that neither the OP nor the user knows what environment variables they want -- they have been set by the installer of the command line utilities. So the OP wants and environment that is just like the users standard shell environment. That doesn't seem unreasonable to me.

One should be able to write a utility in pure python that calls the users default shell, gets the environemnt variables, then sets them in the Python processes environment. /usr/bin/env should help here.

-Chris

···

On 3/15/11 9:35 AM, Robin Dunn wrote:

This is really getting into my nerves now.....

Ok, one more time: Try setting the values in ~/.MacOSX/environment.plist

Or: Ask the user what values to put into the child process' environment
and save the values in a config file for the next time you need them.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Ronald just posted a note to the pythonmac list with a suggestion about how to do this more robustly -- a bit ugly, but doable, and he seems open to includingit in py2app if someone writes it.

-Chris

···

On 3/15/11 10:12 AM, Christopher Barker wrote:

One should be able to write a utility in pure python that calls the
users default shell, gets the environment variables, then sets them in
the Python processes environment. /usr/bin/env should help here.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I'm not seeing that reply, did he not CC the list?

···

On 3/15/11 10:18 AM, Christopher Barker wrote:

On 3/15/11 10:12 AM, Christopher Barker wrote:

One should be able to write a utility in pure python that calls the
users default shell, gets the environment variables, then sets them in
the Python processes environment. /usr/bin/env should help here.

Ronald just posted a note to the pythonmac list with a suggestion about
how to do this more robustly -- a bit ugly, but doable, and he seems
open to includingit in py2app if someone writes it.

--
Robin Dunn
Software Craftsman

Robin,

I did a test with ~/.MacOSX/environment.plist and vars defined in .plist are coming properly. It seems .plist is the only workable solution so far. But there is a catch,
If you are creating a ‘PATH’ key in .plist, it’s going to override ‘PATH’ of process. To over come this problem I am thinking to ship my own
.plist file along with the app bundle. I can parse the key-value pair and store values in os.environ at start up. By parsing I can check if var is already available in os.environ ( example PATH) then append the value in existing key or else create the var. This would be more friendly approach then creating .plist file in ~/.MacOSX directory.

Prashant

Damn…
After defining all the required vars including ‘PATH’, I can’t start the process using short name. I have to specify full path of these external executable to execute. I wonder what’s missing now?
Any way this is not so problematic now compare to earlier. Last option is to check the steps suggested by Ronald in Pythonmac list to emulate
shell environment. I need a bit more practical explanation of what he has suggested then I could give a try.

Prashant