aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Timmons2016-12-11 19:39:56 -0500
committerNoam Postavsky2017-11-05 11:39:06 -0500
commit18af404ef33d8efcbb9446945e543251ab33aa3c (patch)
tree71ffa4cf790e39340e11e7b250a2be2077660438
parentefd0371c23c5dd04d73980b42d7cf64bbceccb9a (diff)
downloademacs-18af404ef33d8efcbb9446945e543251ab33aa3c.tar.gz
emacs-18af404ef33d8efcbb9446945e543251ab33aa3c.zip
Support python virtualenv on w32 (Bug#24464)
According to the virtualenv docs only POSIX systems follow the structure "/path/to/venv/bin/", while windows systems use "/path/to/venv/Scripts" for the location of the binary files, most importantly including the python interpreter (see: https://virtualenv.pypa.io/en/stable/userguide/#windows-notes). * lisp/progmodes/python.el (python-shell-calculate-exec-path): Use the "/path/to/venv/Scripts" for `windows-nt' machines. Copyright-paperwork-exempt: yes
-rw-r--r--lisp/progmodes/python.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index b7902fb9786..d4226e5ce7b 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2113,20 +2113,25 @@ remote host, the returned value is intended for
2113(defun python-shell-calculate-exec-path () 2113(defun python-shell-calculate-exec-path ()
2114 "Calculate `exec-path'. 2114 "Calculate `exec-path'.
2115Prepends `python-shell-exec-path' and adds the binary directory 2115Prepends `python-shell-exec-path' and adds the binary directory
2116for virtualenv if `python-shell-virtualenv-root' is set. If 2116for virtualenv if `python-shell-virtualenv-root' is set - this
2117`default-directory' points to a remote host, the returned value 2117will use the python interpreter from inside the virtualenv when
2118appends `python-shell-remote-exec-path' instead of `exec-path'." 2118starting the shell. If `default-directory' points to a remote host,
2119the returned value appends `python-shell-remote-exec-path' instead
2120of `exec-path'."
2119 (let ((new-path (copy-sequence 2121 (let ((new-path (copy-sequence
2120 (if (file-remote-p default-directory) 2122 (if (file-remote-p default-directory)
2121 python-shell-remote-exec-path 2123 python-shell-remote-exec-path
2122 exec-path)))) 2124 exec-path)))
2125
2126 ;; Windows and POSIX systems use different venv directory structures
2127 (virtualenv-bin-dir (if (eq system-type 'windows-nt) "Scripts" "bin")))
2123 (python-shell--add-to-path-with-priority 2128 (python-shell--add-to-path-with-priority
2124 new-path python-shell-exec-path) 2129 new-path python-shell-exec-path)
2125 (if (not python-shell-virtualenv-root) 2130 (if (not python-shell-virtualenv-root)
2126 new-path 2131 new-path
2127 (python-shell--add-to-path-with-priority 2132 (python-shell--add-to-path-with-priority
2128 new-path 2133 new-path
2129 (list (expand-file-name "bin" python-shell-virtualenv-root))) 2134 (list (expand-file-name virtualenv-bin-dir python-shell-virtualenv-root)))
2130 new-path))) 2135 new-path)))
2131 2136
2132(defun python-shell-tramp-refresh-remote-path (vec paths) 2137(defun python-shell-tramp-refresh-remote-path (vec paths)