From 08509cbd985110810444673a5c584dd23caa24ac Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Wed, 29 Aug 2012 01:36:35 +0200 Subject: [PATCH 1/3] Fix for windows --- virtualenv.el | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/virtualenv.el b/virtualenv.el index 1b632d5..fa71314 100644 --- a/virtualenv.el +++ b/virtualenv.el @@ -113,6 +113,11 @@ better to use this than for it to appear blank.") (defvar virtualenv-mode-name virtualenv-mode-name-default) +(defvar virtualenv-executables-dir + (if (eq system-type 'windows-nt) "/Scripts" "/bin") + "The name of the directory containing executables. It is system +dependent.") + (defvar virtualenv-default-directory nil "Buffer-local variable that should be set in your project's top-level .dir-locals.el file as the place you want to start the python shell. @@ -214,7 +219,7 @@ the virtual environment or if not a string then query the user." (lambda (d) (when (file-exists-p (expand-file-name - (concat d "/bin") + (concat d virtualenv-executables-dir) root)) d)) (directory-files root nil "^[^.]")))) @@ -239,7 +244,7 @@ the virtual environment or if not a string then query the user." (kill-buffer buffer)) (setq virtualenv-workon-session env) (let* ((bin (expand-file-name - (concat env "/bin") + (concat env virtualenv-executables-dir) virtualenv-root)) (oldpath (or (car virtualenv-saved-path) (getenv "PATH"))) @@ -247,7 +252,12 @@ the virtual environment or if not a string then query the user." exec-path))) (setq virtualenv-saved-path (cons oldpath oldexec)) (add-to-list 'exec-path bin) - (setenv "PATH" (concat bin ":" oldpath))) + (setenv "PATH" + (if (eq system-type 'windows-nt) + (concat bin path-separator + (replace-regexp-in-string + (regexp-quote "/") "\\" oldpath)) + (concat bin path-separator oldpath)))) (when virtualenv-workon-starts-python (cond ((fboundp 'python-shell-switch-to-shell) (python-shell-switch-to-shell)) @@ -316,14 +326,17 @@ the virtual environment or if not a string then query the user." (let* ((activate (expand-file-name "activate" (expand-file-name - (concat workon "/bin") + (concat workon virtualenv-executables-dir) virtualenv-root))) (process-environment (when (file-exists-p activate) (split-string (shell-command-to-string + (if (eq system-type 'windows-nt) + (format "call %s; (cd %s && set)" + activate default-directory) ; TODO Fixme (format "source %s; (cd %s && env)" - activate default-directory)) + activate default-directory))) "\n"))) (exec-path (split-string (getenv "PATH") path-separator))) ad-do-it From 12cec19b8910ece2d9d0721475a81a2702318873 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Wed, 29 Aug 2012 09:41:17 +0200 Subject: [PATCH 2/3] Fix windows command --- virtualenv.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenv.el b/virtualenv.el index fa71314..8c810e1 100644 --- a/virtualenv.el +++ b/virtualenv.el @@ -333,8 +333,8 @@ the virtual environment or if not a string then query the user." (split-string (shell-command-to-string (if (eq system-type 'windows-nt) - (format "call %s; (cd %s && set)" - activate default-directory) ; TODO Fixme + (format "call %s & cd %s && set" + activate default-directory) (format "source %s; (cd %s && env)" activate default-directory))) "\n"))) From 6e56be55db073e729fc2bc29ef7f15bd251822a5 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Wed, 29 Aug 2012 09:41:46 +0200 Subject: [PATCH 3/3] Fix typo --- virtualenv.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenv.el b/virtualenv.el index 8c810e1..6c601e4 100644 --- a/virtualenv.el +++ b/virtualenv.el @@ -166,7 +166,7 @@ not set, then use `virtualenv-mode-name-default'." (make-local-variable 'virtualenv-mode-name) (setq virtualenv-mode-name string))) -(defalias 'virutalenv-old-hack-dir-local-variables (symbol-function 'hack-dir-local-variables)) +(defalias 'virtualenv-old-hack-dir-local-variables (symbol-function 'hack-dir-local-variables)) ;;;###autoload (defun virtualenv-workon (&optional env)