Use poetry to manage virtualenvs

This commit is contained in:
Ohad Livne 2025-06-04 22:45:14 +03:00
parent b4bf1d5c6d
commit fcb9cc02f9
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D
5 changed files with 22 additions and 28 deletions

View file

@ -138,25 +138,15 @@
("C-c C-p" . flycheck-previous-error)
("C-c C-l" . flycheck-list-errors)))
(use-package pyvenv)
(defun find-venv ()
"Try to find a .venv/ directory in the current project"
(require 'f)
(let ((basedir (f-traverse-upwards
(lambda (path)
(let ((venv-path (f-expand ".venv" path)))
(f-exists? venv-path))))))
(when basedir (f-expand ".venv" basedir))))
; Requires poetry to be installed
(use-package poetry)
(defun load-python-env ()
"Set up the Python IDE in the current project"
(interactive)
(let ((venv-dir (find-venv)))
(when venv-dir
(progn
(pyvenv-activate venv-dir)
(lsp)))))
(progn
(poetry-venv-workon)
(lsp)))
(defun symbols-at-point ()
(let* ((lsp--document-symbols-request-async t)

View file

@ -21,7 +21,6 @@ network-manager \
pipx \
postfix \
pulseaudio-utils \
python3-venv
sway \
swayidle \
swaylock \
@ -32,8 +31,12 @@ xournalpp \
"
PIPX_PKGS="\
poetry \
yt-dlp \
"
sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes ${DEB_PKGS}
pipx install ${PIPX_PKGS}
for pkg in ${PIPX_PKGS};
do
pipx install "${pkg}"
done