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 <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@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to