rejeep / prodigy.el

Manage external services from within Emacs
GNU General Public License v3.0
552 stars 39 forks source link

How to use with python virtualenv #31

Closed istib closed 10 years ago

istib commented 10 years ago

virtualenvs for python apps are activated using the following bash syntax: source ~/.virtualenvs/[ENV]/bin/activate

because the script cannot be an actual bash file. Trying this as prodigy process fails however:

(prodigy-define-service :name "server" :command "source ~/.virtualenvs/myenv/bin/activate && python manage.py runserver" :cwd "~/myapp/" :path '("~/.virtualenvs/myenv/bin/"))

rejeep commented 10 years ago

The arguments are separated from the command. Can you try:

(prodigy-define-service
  :name "server"
  :command "source"
  :args '("~/.virtualenvs/myenv/bin/activate" "&&" "python" "manage.py" "runserver")
  :cwd "~/myapp/"
  :path '("~/.virtualenvs/myenv/bin/"))
istib commented 10 years ago

Thanks for that. The problem seems to be that the process caller doesn't recognize the shell built-in command 'source'. Here's the output from your version: "apply: Searching for program: no such file or directory, source"

rejeep commented 10 years ago

Try using bash -c. For example instead of:

$ source foo.sh

Use:

$ bash -c 'source foo.sh'
istib commented 10 years ago

Thank you. I didn't get it to work with combination of "bash -c", but using virtualenvwrapper.el to activate the environment does the trick:

(prodigy-define-service
  :name "runserver"
  :command "python"
  :args '("manage.py" "runserver")
  :cwd "path/to/server"
  :kill-signal 'sigkill
  :kill-process-buffer-on-stop t
  :init (lambda () (venv-workon "virtualenv/name")))
rejeep commented 10 years ago

Glad it worked out for you!