Skip to content

Commit

Permalink
env: Python version lookup improvements (seagle0128#666)
Browse files Browse the repository at this point in the history
* env/python: Avoid pipenv package dependency

Since `pipenv-project-p` just boils down to a simple
`locate-dominating-file` avoid depending on it for finding `pipenv`
repositories. This helps users that uses `pipenv` but doesn't use
https://github.com/pwalsh/pipenv.el

See: https://github.com/pwalsh/pipenv.el/blob/master/pipenv.el#L367-L369

* env/python: Find python via direnv

If pipenv and pyenv fails, try to find python via direnv.
  • Loading branch information
mattiasb authored Sep 21, 2023
1 parent 93f240f commit ec62bcd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions doom-modeline-env.el
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,25 @@ PARSER should be a function for parsing COMMAND's output line-by-line, to
;;;###autoload (autoload 'doom-modeline-env-setup-python "doom-modeline-env")
(doom-modeline-def-env python
:hooks '(python-mode-hook python-ts-mode-hook)
:command (lambda () (cond ((and (fboundp 'pipenv-project-p)
(pipenv-project-p))
:command (lambda () (cond ((and (executable-find "pipenv")
(locate-dominating-file default-directory "Pipfile"))
(list "pipenv" "run"
(or doom-modeline-env-python-executable
python-shell-interpreter
"python")
"--version"))
((executable-find "pyenv") (list "pyenv" "version-name"))
((and (executable-find "direnv")
(locate-dominating-file default-directory ".envrc"))
(list "bash"
"-c"
;; Direnv unfortunately writes crao on stderr
;; so we need to pipe that to /dev/null
(format "'direnv exec %s %s --version 2>/dev/null'"
default-directory
(or doom-modeline-env-python-executable
python-shell-interpreter
"python"))))
((list (or doom-modeline-env-python-executable
python-shell-interpreter
"python")
Expand Down

0 comments on commit ec62bcd

Please sign in to comment.