mirror of
https://github.com/doomemacs/doomemacs.git
synced 2026-01-11 11:41:39 -08:00
feat(python): add uv support
Also takes this opportunity to update some missing package metadata in the module's documentation. Close: #8596 Co-authored-by: DamianB-BitFlipper <DamianB-BitFlipper@users.noreply.github.com>
This commit is contained in:
parent
b545ce0750
commit
b851bcd3a0
4 changed files with 32 additions and 4 deletions
|
|
@ -30,21 +30,26 @@ This module adds [[https://www.python.org/][Python]] support to Doom Emacs.
|
|||
Enable Python packaging, dependency management, and virtual environment
|
||||
support via [[https://python-poetry.org/][Poetry]].
|
||||
- +pyenv ::
|
||||
Enable Python virtual environment support via [[https://github.com/pyenv/pyenv][pyenv]]
|
||||
Enable Python virtual environment support via [[https://github.com/pyenv/pyenv][pyenv]]. Cannot be used together
|
||||
with [[doom-module:+uv]].
|
||||
- +pyright ::
|
||||
Add support for the pyright LSP server (requires [[doom-module:+lsp]]).
|
||||
- +tree-sitter ::
|
||||
Leverages tree-sitter for better syntax highlighting and structural text
|
||||
editing. Requires [[doom-module::tools tree-sitter]]. Support is much improved on
|
||||
Emacs 30 and newer.
|
||||
- +uv ::
|
||||
Enable Python virtual environment support via [[https://github.com/astral-sh/uv][uv]]. Cannot be used together with
|
||||
[[doom-module:+pyenv]].
|
||||
|
||||
** Packages
|
||||
- [[doom-package:conda]]
|
||||
- [[doom-package:conda]] if [[doom-module:+conda]]
|
||||
- [[doom-package:nose]]
|
||||
- [[doom-package:pipenv]]
|
||||
- [[doom-package:pip-requirements]]
|
||||
- [[doom-package:poetry]] if [[doom-module:+poetry]]
|
||||
- [[doom-package:pyenv]]
|
||||
- [[doom-package:pyenv]] if [[doom-module:+pyenv]]
|
||||
- [[doom-package:uvenv]] if [[doom-module:+uv]]
|
||||
- [[doom-package:pyimport]]
|
||||
- [[doom-package:py-isort]]
|
||||
- [[doom-package:python-pytest]]
|
||||
|
|
@ -74,6 +79,7 @@ This module has no hard requirements, but softly depends on:
|
|||
- [[doom-package:py-isort]] requires [[https://github.com/timothycrosley/isort][isort]] to be installed: ~pip install isort~
|
||||
- Python virtual environments install instructions at:
|
||||
- [[https://github.com/pyenv/pyenv][pyenv]]
|
||||
- [[https://github.com/astral-sh/uv][uv]]
|
||||
- [[https://conda.io/en/latest/][Conda]]
|
||||
- [[https://python-poetry.org/][Poetry]]
|
||||
- [[https://pipenv.readthedocs.io/en/latest/][pipenv]]
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
(setq-local flycheck-python-pylint-executable "pylint")
|
||||
(setq-local flycheck-python-flake8-executable "flake8"))))
|
||||
|
||||
;; Affects pyenv and conda
|
||||
;; Affects pyenv, uv, and conda
|
||||
(when (modulep! :ui modeline)
|
||||
(advice-add #'pythonic-activate :after-while #'+modeline-update-env-in-all-windows-h)
|
||||
(advice-add #'pythonic-deactivate :after #'+modeline-clear-env-in-all-windows-h))
|
||||
|
|
@ -216,6 +216,19 @@
|
|||
(add-hook 'doom-switch-buffer-hook #'+python-pyenv-mode-set-auto-h))
|
||||
|
||||
|
||||
(use-package! uv-mode
|
||||
:when (modulep! +uv)
|
||||
:after python
|
||||
:config
|
||||
;; HACK: A faster (cached) version of the mode-line segment. See
|
||||
;; `+python-uv-mode-set-auto-h'.
|
||||
(setq uv-mode-mode-line-format '(+python--uv-version ("UV:" +python--uv-version " ")))
|
||||
(if (executable-find "uv") (uv-mode +1))
|
||||
(add-hook! '(python-mode-local-vars-hook python-ts-mode-local-vars-hook)
|
||||
#'+python-uv-mode-set-auto-h)
|
||||
(add-hook 'doom-switch-buffer-hook #'+python-uv-mode-set-auto-h))
|
||||
|
||||
|
||||
(use-package! conda
|
||||
:when (modulep! +conda)
|
||||
:after python
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
(fboundp 'python-ts-mode))
|
||||
"Can't find `python-ts-mode'; Emacs 29.1+ is required")
|
||||
|
||||
(assert! (not (and (modulep! +pyenv) (modulep! +uv)))
|
||||
"The +pyenv and +uv flags cannot be used together")
|
||||
|
||||
(unless (or (executable-find "python")
|
||||
(executable-find "python3"))
|
||||
(error! "Couldn't find python in your PATH"))
|
||||
|
|
@ -22,6 +25,10 @@
|
|||
(unless (split-string (shell-command-to-string "pyenv versions --bare") "\n" t)
|
||||
(warn! "No versions of python are available via pyenv, did you forget to install one?"))))
|
||||
|
||||
(when (modulep! +uv)
|
||||
(unless (executable-find "uv")
|
||||
(warn! "Couldn't find uv in your PATH")))
|
||||
|
||||
(when (modulep! +conda)
|
||||
(unless (executable-find "conda")
|
||||
(warn! "Couldn't find conda in your PATH")))
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
(package! pyvenv :pin "31ea715f2164dd611e7fc77b26390ef3ca93509b")
|
||||
(when (modulep! +pyenv)
|
||||
(package! pyenv-mode :pin "8e5128ff7f722a4d68ddaa22022cb99ef9ddcf9a"))
|
||||
(when (modulep! +uv)
|
||||
(package! uv-mode :pin "7e7f9b90832210b65823c3d58e3255cd164394b7"))
|
||||
(when (modulep! +conda)
|
||||
(package! conda :pin "82b9f77a7f7d5c6ea91e06c5bd54d8a43a75f977"))
|
||||
(when (modulep! +poetry)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue