lang/python: fix pyenv version detection #736

This commit is contained in:
Henrik Lissner 2018-07-06 23:56:50 +02:00
parent 55f692491e
commit 0a577f3a0e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -67,14 +67,14 @@ is loaded.")
(add-hook 'python-mode-hook #'+python|add-version-to-modeline) (add-hook 'python-mode-hook #'+python|add-version-to-modeline)
(if (not (executable-find "pyenv")) (if (not (executable-find "pyenv"))
(setq +python-current-version (string-trim (shell-command-to-string "python --version 2>&1 | cut -d' ' -f2"))) (setq-default +python-current-version (string-trim (shell-command-to-string "python --version 2>&1 | cut -d' ' -f2")))
(setq +python-pyenv-root (string-trim (shell-command-to-string "pyenv root")) (setq +python-pyenv-root (string-trim (shell-command-to-string "pyenv root"))
+python-pyenv-versions (split-string (shell-command-to-string "pyenv versions --bare") "\n" t)) +python-pyenv-versions (split-string (shell-command-to-string "pyenv versions --bare") "\n" t))
(defun +python|detect-pyenv-version () (defun +python|detect-pyenv-version ()
"Detect the pyenv version for the current project and set the relevant "Detect the pyenv version for the current project and set the relevant
environment variables." environment variables."
(when-let* ((version-str (shell-command-to-string "python --version 2>&1 | cut -d' ' -f2"))) (when-let* ((version-str (shell-command-to-string "PYENV_VERSION= python --version 2>&1 | cut -d' ' -f2")))
(setq version-str (string-trim version-str) (setq version-str (string-trim version-str)
+python-current-version version-str) +python-current-version version-str)
(let ((pyenv-current-path (concat +python-pyenv-root "/versions/" version-str))) (let ((pyenv-current-path (concat +python-pyenv-root "/versions/" version-str)))