[Pythonmac-SIG] Lanchd + virtualenv

Gabriel Rossetti gabriel.rossetti at arimaz.com
Fri Sep 25 14:56:06 CEST 2009


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?


More information about the Pythonmac-SIG mailing list