Fix conflict between pipenv directory .venv and pyvenv file .venv

This commit is contained in:
rgb-24bit 2018-11-12 18:23:00 +08:00 committed by Codruț Constantin Gușoi
parent 7857bcae4d
commit c2a351cac7
2 changed files with 12 additions and 6 deletions

View File

@ -1722,6 +1722,8 @@ Benner and Paweł Siudak):
JimmyG)
- Highlight python3.7 builtin =breakpoint()= function (thanks to Boris
Verhovsky)
- Fix conflict between pipenv directory .venv and pyvenv file .venv (thanks to
rgb-24bit)
**** Racket
- Restore smart closing paren behavior in racket-mode (thanks to Don March)
**** Ranger

View File

@ -212,18 +212,22 @@ as the pyenv version then also return nil. This works around https://github.com/
version file-path))))))
(defun spacemacs//pyvenv-mode-set-local-virtualenv ()
"Set pyvenv virtualenv from \".venv\" by looking in parent directories."
"Set pyvenv virtualenv from \".venv\" by looking in parent directories. handle directory or file"
(interactive)
(let ((root-path (locate-dominating-file default-directory
".venv")))
(when root-path
(let* ((file-path (expand-file-name ".venv" root-path))
(virtualenv
(with-temp-buffer
(insert-file-contents-literally file-path)
(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))))
(pyvenv-workon virtualenv)))))
(if (file-directory-p file-path)
file-path
(with-temp-buffer
(insert-file-contents-literally file-path)
(buffer-substring-no-properties (line-beginning-position)
(line-end-position))))))
(if (file-directory-p virtualenv)
(pyvenv-activate virtualenv)
(pyvenv-workon virtualenv))))))
;; Tests