I have a lot of environment variables set in /etc/profile and ~/.profile 
which I need passed through to the Spyder environment. When starting from 
the terminal, this is not a problem because the python environment of 
Spyder inherits from the bash environment (which sources /etc/profile and 
~/.profile). However, in your script, since python is run from a 
non-interactive shell (OS application startup), the profile files are not 
sourced. To solve this problem I modified the script as follows:

#! /opt/local/bin/python

import os
import subprocess

envstr = subprocess.check_output('source /etc/profile; source ~/.profile; 
printenv', shell=True)
env = [a.split('=') for a in envstr.strip().split('\n')]
os.environ.update(env)

executable = '/opt/local/bin/spyder'
arguments = [executable]

os.execve(executable, arguments, os.environ)

the check_output executes the source commands, after which I tell it to 
output all the environment variables which are then returned as a single 
string. The string is parsed into key-value pairs and used to update the 
os.environ dictionary.

Ryan Clary

On Sunday, April 22, 2012 9:02:22 AM UTC-7, Petrush wrote:
>
> Hi, 
>
> I managed to make a dock-icon / app for Mac osx using the instructions 
> for IPython at http://neuroscience.telenczuk.pl/?p=400 
>
> Basically: 
>
> Create a directory Spyder.app 
> Create a subdir "Contents" 
>
> In "Contents" create a Info.plist containing: 
> <?xml version="1.0" encoding="UTF-8"?> 
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:// 
> www.apple.com/DTDs/PropertyList-1.0.dtd"> 
> <plist version="1.0"> 
> <dict> 
>     <key>CFBundleIconFile</key> 
>     <string>spyder</string> 
> </dict> 
> </plist> 
>
> Create two directories in "Content": "MacOS" and "Resources" 
>
> In MacOS put the startup file (not sure the PYTHONPATH stuff is needed 
> really): 
>
> #! /opt/local/bin/python 
>
> import os 
> executable = '/opt/local/bin/spyder' 
> arguments = [executable] 
> os.environ["PYTHONPATH"]=os.getenv("PYTHONPATH", "") 
> os.execve(executable, arguments, os.environ) 
>
> In Resources dir, create an icon using XCode and iconcomposer. 
>
> With this spyder can be launched as an app, and made to stay in the 
> dock. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/spyderlib/-/i1390C9nz3MJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/spyderlib?hl=en.

Reply via email to