emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 18af404 3/3: Support python virtualenv on w32 (Bu


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 18af404 3/3: Support python virtualenv on w32 (Bug#24464)
Date: Sun, 5 Nov 2017 12:16:07 -0500 (EST)

branch: emacs-26
commit 18af404ef33d8efcbb9446945e543251ab33aa3c
Author: Justin Timmons <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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
---
 lisp/progmodes/python.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index b7902fb..d4226e5 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2113,20 +2113,25 @@ remote host, the returned value is intended for
 (defun python-shell-calculate-exec-path ()
   "Calculate `exec-path'.
 Prepends `python-shell-exec-path' and adds the binary directory
-for virtualenv if `python-shell-virtualenv-root' is set.  If
-`default-directory' points to a remote host, the returned value
-appends `python-shell-remote-exec-path' instead of `exec-path'."
+for virtualenv if `python-shell-virtualenv-root' is set - this
+will use the python interpreter from inside the virtualenv when
+starting the shell.  If `default-directory' points to a remote host,
+the returned value appends `python-shell-remote-exec-path' instead
+of `exec-path'."
   (let ((new-path (copy-sequence
                    (if (file-remote-p default-directory)
                        python-shell-remote-exec-path
-                     exec-path))))
+                     exec-path)))
+
+        ;; Windows and POSIX systems use different venv directory structures
+        (virtualenv-bin-dir (if (eq system-type 'windows-nt) "Scripts" "bin")))
     (python-shell--add-to-path-with-priority
      new-path python-shell-exec-path)
     (if (not python-shell-virtualenv-root)
         new-path
       (python-shell--add-to-path-with-priority
        new-path
-       (list (expand-file-name "bin" python-shell-virtualenv-root)))
+       (list (expand-file-name virtualenv-bin-dir 
python-shell-virtualenv-root)))
       new-path)))
 
 (defun python-shell-tramp-refresh-remote-path (vec paths)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]