Spyder in the dock and as app for Mac OSX

1,381 views
Skip to first unread message

Petrush

unread,
Apr 22, 2012, 12:02:22 PM4/22/12
to spyder
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.

mangecoeur

unread,
Apr 24, 2012, 5:45:42 AM4/24/12
to spyd...@googlegroups.com
When you do it this way do you also get the python rocket icon: in the dock? I have a way to do the same thing using apple script but when it runs you get the app icon and the rocket icon in the dock

Petrush

unread,
Apr 25, 2012, 4:30:19 PM4/25/12
to spyder
On Apr 24, 11:45 am, mangecoeur <jon.chambers3...@gmail.com> wrote:
> When you do it this way do you also get the python rocket icon: in the dock? I have a way to do the same thing using apple script but when it runs you get the app icon and the rocket icon in the dock

Yes the rocket icon is still there, and plot windows are not
associated with the spyder app.

Ryan Clary

unread,
Apr 25, 2012, 5:02:13 PM4/25/12
to spyd...@googlegroups.com
I think this deserves some clarification…
When starting Spyder from the terminal, a rocket icon appears in the dock for Spyder.
If Spyder starts an iPython interpreter, then two rockets appear, one for Spyder and one for the iPython interpreter.

If you implement the application mentioned before (thanks, by the way!), then a rocket icon does NOT appear in the dock for Spyder, but a rocket icon will appear for the iPython interpreter.

Ryan Clary
> --
> You received this message because you are subscribed to the Google Groups "spyder" group.
> To post to this group, send email to spyd...@googlegroups.com.
> To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.
>

mrclary

unread,
Apr 25, 2012, 10:59:23 PM4/25/12
to spyd...@googlegroups.com
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

Petrush

unread,
Apr 26, 2012, 4:46:10 AM4/26/12
to spyder
Thanks for the clarification!

Somehow I do not see these tasks as separately visible in windows /
linux (not completely sure).

When python programs are launched from the terminal they seem to have
no rocket icon either? Could the tasks be launched this way instead
somehow?

Regards

Nate O

unread,
May 8, 2012, 10:22:20 PM5/8/12
to spyder
What's the file appending for the startup script that is put into
MacOS?

Ryan Clary

unread,
May 9, 2012, 10:48:26 AM5/9/12
to spyd...@googlegroups.com
It does not require an extension, only executable permissions.

Ryan Clary
Sent from my iPhone

On May 8, 2012, at 9:40 PM, Nate O <nathan.o...@gmail.com> wrote:

> What's the file appending for the startup script that is put into
> MacOS?
>
Reply all
Reply to author
Forward
0 new messages