|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Lanchd + virtualenvHello 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 <dict> emtries : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.example.virtualenv</string> <key>Program</key> <string>source</string> <key>ProgramArguments</key> <array> <string>/path/to/myvirtualenv/bin/activate</string> </array> <key>RunAtLoad</key> <true/> </dict> <dict> <key>Label</key> <string>com.example.app</string> <key>Program</key> <string>python</string> <key>ProgramArguments</key> <array> <string>/path/to/myproj/launcher.py</string> <string>start</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> but I'm not sure I can do that, and I have 2 programs to run for my project, so would I create 3<dict> entries like so : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <!-- The virtualenv --> <dict> <key>Label</key> <string>com.example.virtualenv</string> <key>Program</key> <string>source</string> <key>ProgramArguments</key> <array> <string>/path/to/myvirtualenv/bin/activate</string> </array> <key>RunAtLoad</key> <true/> </dict> <!-- My app 1 --> <dict> <key>Label</key> <string>com.example.app1</string> <key>Program</key> <string>python</string> <key>ProgramArguments</key> <array> <string>/path/to/myproj/launcher.py</string> <string>app1</string> <string>start</string> </array> <key>RunAtLoad</key> <true/> </dict> <!-- My app 2 --> <dict> <key>Label</key> <string>com.example.app2</string> <key>Program</key> <string>python</string> <key>ProgramArguments</key> <array> <string>/path/to/myproj/launcher.py</string> <string>app2</string> <string>start</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> Or is there a better/another way to do this? _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvOn Fri, Sep 25, 2009, Gabriel Rossetti wrote:
> > 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 <dict> emtries : Why not just write a single wrapper script that creates the virtualenv and then runs the main program? Python rocks! -- Aahz (aahz@...) <*> http://www.pythoncraft.com/ gfarber: Thank God, or the belief system of your choice. pddb: Does human perversity count as a belief system? _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvNo 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 <dict> emtries : > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" > "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> > <plist version="1.0"> > <dict> > <key>Label</key> > <string>com.example.virtualenv</string> > <key>Program</key> > <string>source</string> > <key>ProgramArguments</key> > <array> > <string>/path/to/myvirtualenv/bin/activate</string> > </array> > <key>RunAtLoad</key> > <true/> > </dict> > <dict> > <key>Label</key> > <string>com.example.app</string> > <key>Program</key> > <string>python</string> > <key>ProgramArguments</key> > <array> > <string>/path/to/myproj/launcher.py</string> > <string>start</string> > </array> > <key>RunAtLoad</key> > <true/> > </dict> > </plist> > > > but I'm not sure I can do that, and I have 2 programs to run for my > project, so would I create 3<dict> entries like so : > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" > "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> > <plist version="1.0"> > <!-- The virtualenv --> > <dict> > <key>Label</key> > <string>com.example.virtualenv</string> > <key>Program</key> > <string>source</string> > <key>ProgramArguments</key> > <array> > <string>/path/to/myvirtualenv/bin/activate</string> > </array> > <key>RunAtLoad</key> > <true/> > </dict> > <!-- My app 1 --> > <dict> > <key>Label</key> > <string>com.example.app1</string> > <key>Program</key> > <string>python</string> > <key>ProgramArguments</key> > <array> > <string>/path/to/myproj/launcher.py</string> > <string>app1</string> > <string>start</string> > </array> > <key>RunAtLoad</key> > <true/> > </dict> > <!-- My app 2 --> > <dict> > <key>Label</key> > <string>com.example.app2</string> > <key>Program</key> > <string>python</string> > <key>ProgramArguments</key> > <array> > <string>/path/to/myproj/launcher.py</string> > <string>app2</string> > <string>start</string> > </array> > <key>RunAtLoad</key> > <true/> > </dict> > </plist> > > Or is there a better/another way to do this? > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@... > http://mail.python.org/mailman/listinfo/pythonmac-sig _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
|
|
|
Re: Lanchd + virtualenvOn 25 Σεπ 2009, at 6:31 μ.μ., gabriel.rossetti@... 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 > > Gabriel > > > On Fri 25/09/09 17:01 , "Orestis Markou" orestis@... 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@... > > http://mail.python.org/mailman/listinfo/pythonmac-sig">http:// > mail.python.org/mailman/listinfo/pythonmac-sig > > _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvOrestis Markou wrote: > > On 25 Σεπ 2009, at 6:31 μ.μ., gabriel.rossetti@... 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@... 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@... >> > >> http://mail.python.org/mailman/listinfo/pythonmac-sig">http://mail.python.org/mailman/listinfo/pythonmac-sig >> >> >> > Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvOn 25 Sep, 2009, at 14: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. Unless you do something special you don't have to activate the virtualenv at all, just make sure that the '#!' line in the script you're starting refers to the python in the virtualenv (instead of having '#!/usr/bin/env python'). I have a virtualenv containing a mercurial installation and regularly use the mercurial command-line tools without activating the virtualenv. Ronald _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvRonald Oussoren wrote:
> > On 25 Sep, 2009, at 14: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. > > Unless you do something special you don't have to activate the > virtualenv at all, just make sure that the '#!' line in the script > you're starting refers to the python in the virtualenv (instead of > having '#!/usr/bin/env python'). > > I have a virtualenv containing a mercurial installation and regularly > use the mercurial command-line tools without activating the virtualenv. > > Ronald > have to install a package into it. Gabriel _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Lanchd + virtualenvOn 30 Sep, 2009, at 17:31, Gabriel Rossetti wrote: > Ronald Oussoren wrote: >> >> On 25 Sep, 2009, at 14: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. >> >> Unless you do something special you don't have to activate the >> virtualenv at all, just make sure that the '#!' line in the script >> you're starting refers to the python in the virtualenv (instead of >> having '#!/usr/bin/env python'). >> >> I have a virtualenv containing a mercurial installation and >> regularly use the mercurial command-line tools without activating >> the virtualenv. >> >> Ronald >> > Ok, thanks, so from what I understand I only need to activate it if > I have to install a package into it. virtualenv on your shell's search-path (that is $PATH). Activating is handy when you are installing software, but is also needed when a script in the virtualenv executes another script in the environment and assumes that that other script is on the search-path. Ronald > > Gabriel _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
| Free embeddable forum powered by Nabble | Forum Help |