[Pythonmac-SIG] Lanchd + virtualenv

Gabriel Rossetti gabriel.rossetti at arimaz.com
Fri Sep 25 18:25:37 CEST 2009


Orestis Markou wrote:
>
> On 25 Σεπ 2009, at 6:31 μ.μ., gabriel.rossetti at arimaz.com wrote:
>
>> How about running the python exec directly from the virtual env :
>>
>> and again it seams to work (correct me again if I messed up somewhere).
>>
>> What is the advantage of using your method?
>
> None in particular, apart from the fact that a python script can be 
> more flexible in deciding whether to activate a virtualenv or not, or 
> even which virtualenv. If you are certain that the virtualenv will 
> always be at the same place, then hardcoding it into the .plist is fine.
>
> In my case, this snippet appears in a pyobjc app, where I don't have a 
> lot of control on which python is used (it's complicated).
>
> Orestis

Ok, in my case I control everything so I'll hardcode it. I'll keep your 
msg in a corner as I may one day need it, thank you for the explanation 
and help.

>
>>
>> Gabriel
>>
>>
>> On Fri 25/09/09 17:01 , "Orestis Markou" orestis at orestis.gr sent:
>> No need for a wrapper script. In recent versions of virtualenv, you
>> can do this:
>>
>> activate_this = 'path/to/virtualenv/bin/activate_this.py'
>> if os.path.exists(activate_this):
>> execfile(activate_this, dict(__file__=activate_this))
>>
>> On 25 Σεπ 2009, at 3:56 μ.μ., Gabriel Rossetti wrote:
>>
>> > Hello everyone,
>> >
>> > I would like to create a Launchd plist entry to start a virtualenv
>> > and run a python project. I created my plist, but I'm not sure how
>> > to get it to activate the virtualenv and run the program. I thought
>> > that maybe I could create two emtries :
>> >
>> >
>> >
>> > 
>> "http://www.apple.com/DTDs/PropertyList-1.0.dtd%26quot%3B%26gt">http://www.apple.com/DTDs/PropertyList-1.0.dtd">; 
>>
>> >
>> >
>> > Label
>> > com.example.virtualenv
>> > Program
>> > source
>> > ProgramArguments
>> >
>> > /path/to/myvirtualenv/bin/activate
>> >
>> > RunAtLoad
>> >
>> >
>> >
>> > Label
>> > com.example.app
>> > Program
>> > python
>> > ProgramArguments
>> >
>> > /path/to/myproj/launcher.py
>> > start
>> >
>> > RunAtLoad
>> >
>> >
>> >
>> >
>> >
>> > but I'm not sure I can do that, and I have 2 programs to run for my
>> > project, so would I create 3 entries like so :
>> >
>> >
>> >
>> > 
>> "http://www.apple.com/DTDs/PropertyList-1.0.dtd%26quot%3B%26gt">http://www.apple.com/DTDs/PropertyList-1.0.dtd">; 
>>
>> >
>> >
>> >
>> > Label
>> > com.example.virtualenv
>> > Program
>> > source
>> > ProgramArguments
>> >
>> > /path/to/myvirtualenv/bin/activate
>> >
>> > RunAtLoad
>> >
>> >
>> >
>> >
>> > Label
>> > com.example.app1
>> > Program
>> > python
>> > ProgramArguments
>> >
>> > /path/to/myproj/launcher.py
>> > app1
>> > start
>> >
>> > RunAtLoad
>> >
>> >
>> >
>> >
>> > Label
>> > com.example.app2
>> > Program
>> > python
>> > ProgramArguments
>> >
>> > /path/to/myproj/launcher.py
>> > app2
>> > start
>> >
>> > RunAtLoad
>> >
>> >
>> >
>> >
>> > Or is there a better/another way to do this?
>> > _______________________________________________
>> > Pythonmac-SIG maillist - Pythonmac-SIG at python.org
>> > 
>> http://mail.python.org/mailman/listinfo/pythonmac-sig">http://mail.python.org/mailman/listinfo/pythonmac-sig 
>>
>>
>>
>


More information about the Pythonmac-SIG mailing list