Date: Wed, 25 Apr 2012 19:59:23 -0700 (PDT) From: mrclary To: spyderlib@googlegroups.com Message-ID: <18089452.4436.1335409163589.JavaMail.geo-discussion-forums@vbuo17> In-Reply-To: <004709e8-494b-412d-9f99-4267ecfbb515@m7g2000vbg.googlegroups.com> References: <004709e8-494b-412d-9f99-4267ecfbb515@m7g2000vbg.googlegroups.com> Subject: Re: Spyder in the dock and as app for Mac OSX MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_4434_28006617.1335409163581" ------=_Part_4434_28006617.1335409163581 Content-Type: multipart/alternative; boundary="----=_Part_4435_1769936.1335409163588" ------=_Part_4435_1769936.1335409163588 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: > > www.apple.com/DTDs/PropertyList-1.0.dtd"> > > > CFBundleIconFile > spyder > > > > 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. > ------=_Part_4435_1769936.1335409163588 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable I have a lot of environment variables set in /etc/profile and ~/.profile wh= ich I need passed through to the Spyder environment. When starting from the= terminal, this is not a problem because the python environment of Spyder i= nherits from the bash environment (which sources /etc/profile and ~/.profil= e). However, in your script, since python is run from a non-interactive she= ll (OS application startup), the profile files are not sourced. To solve th= is problem I modified the script as follows:

#! /op= t/local/bin/python

import os
import subp= rocess

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

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

os.execve(ex= ecutable, arguments, os.environ)

the check_output execu= tes the source commands, after which I tell it to output all the environmen= t variables which are then returned as a single string. The string is parse= d into key-value pairs and used to update the os.environ dictionary.
<= div>
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=3D400

Basically:

Create a directory Spyder.app
Create a subdir "Contents"

In "Contents" create a Info.plist containing:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version=3D"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 =3D '/opt/local/bin/spyder'
arguments =3D [executable]
os.environ["PYTHONPATH"]=3Dos.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.
------=_Part_4435_1769936.1335409163588-- ------=_Part_4434_28006617.1335409163581--