aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:10 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:10 -0300
commit66bbb27f8dc210f81beec6a11a8613efefd1d5ad (patch)
treeb7b36ceb3fc5d9c714f659dcb7f0ddeb2fc0cf97 /lisp/progmodes/python.el
parent30e429dd37d8a97afcf0129f8fe498438a611d65 (diff)
downloademacs-66bbb27f8dc210f81beec6a11a8613efefd1d5ad.tar.gz
emacs-66bbb27f8dc210f81beec6a11a8613efefd1d5ad.zip
new variables python-shell-process-environment and python-shell-exec-path
The main reason for these new variables is virtualenv support.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el52
1 files changed, 51 insertions, 1 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 94035546c6e..dc7e46dc129 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -78,6 +78,26 @@
78;; pyreadline from http://ipython.scipy.org/moin/PyReadline/Intro and 78;; pyreadline from http://ipython.scipy.org/moin/PyReadline/Intro and
79;; you should be good to go. 79;; you should be good to go.
80 80
81;; The shell also contains support for virtualenvs and other special
82;; environment modification thanks to
83;; `python-shell-process-environment' and `python-shell-exec-path'.
84;; These two variables allows you to modify execution paths and
85;; enviroment variables to make easy for you to setup virtualenv rules
86;; or behaviors modifications when running shells. Here is an example
87;; of how to make shell processes to be run using the /path/to/env/
88;; virtualenv:
89
90;; (setq python-shell-process-environment
91;; (list
92;; (format "PATH=%s" (mapconcat
93;; 'identity
94;; (reverse
95;; (cons (getenv "PATH")
96;; '("/path/to/env/bin/")))
97;; ":"))
98;; "VIRTUAL_ENV=/path/to/env/"))
99;; (python-shell-exec-path . ("/path/to/env/bin/"))
100
81;; Pdb tracking: when you execute a block of code that contains some 101;; Pdb tracking: when you execute a block of code that contains some
82;; call to pdb (or ipdb) it will prompt the block of code and will 102;; call to pdb (or ipdb) it will prompt the block of code and will
83;; follow the execution of pdb marking the current line with an arrow. 103;; follow the execution of pdb marking the current line with an arrow.
@@ -992,6 +1012,26 @@ returned in that moment and not after waiting."
992 :group 'python 1012 :group 'python
993 :safe 'numberp) 1013 :safe 'numberp)
994 1014
1015(defcustom python-shell-process-environment nil
1016 "List of enviroment variables for Python shell.
1017This variable follows the same rules as `process-enviroment'
1018since it merges with it before the process creation routines are
1019called. When this variable is nil, the Python shell is run with
1020the default `process-enviroment'."
1021 :type '(repeat string)
1022 :group 'python
1023 :safe 'listp)
1024
1025(defcustom python-shell-exec-path nil
1026 "List of path to search for binaries.
1027This variable follows the same rules as `exec-path' since it
1028merges with it before the process creation routines are called.
1029When this variable is nil, the Python shell is run with the
1030default `exec-path'."
1031 :type '(repeat string)
1032 :group 'python
1033 :safe 'listp)
1034
995(defcustom python-shell-setup-codes '(python-shell-completion-setup-code 1035(defcustom python-shell-setup-codes '(python-shell-completion-setup-code
996 python-ffap-setup-code 1036 python-ffap-setup-code
997 python-eldoc-setup-code) 1037 python-eldoc-setup-code)
@@ -1112,7 +1152,17 @@ run).
1112 (read-string "Run Python: " (python-shell-parse-command))) 1152 (read-string "Run Python: " (python-shell-parse-command)))
1113 (list nil (python-shell-parse-command)))) 1153 (list nil (python-shell-parse-command))))
1114 (let* ((proc-name (python-shell-get-process-name dedicated)) 1154 (let* ((proc-name (python-shell-get-process-name dedicated))
1115 (proc-buffer-name (format "*%s*" proc-name))) 1155 (proc-buffer-name (format "*%s*" proc-name))
1156 (process-environment
1157 (if python-shell-process-environment
1158 (merge 'list python-shell-process-environment
1159 process-environment 'string=)
1160 process-environment))
1161 (exec-path
1162 (if python-shell-exec-path
1163 (merge 'list python-shell-exec-path
1164 exec-path 'string=)
1165 exec-path)))
1116 (when (not (comint-check-proc proc-buffer-name)) 1166 (when (not (comint-check-proc proc-buffer-name))
1117 (let ((cmdlist (split-string-and-unquote cmd))) 1167 (let ((cmdlist (split-string-and-unquote cmd)))
1118 (set-buffer 1168 (set-buffer