Skip to content

Commit

Permalink
Merge pull request #2055 from DavidVujic/support-python-3-12-and-later
Browse files Browse the repository at this point in the history
fix(rpc): add support for Python 3.12 and later
  • Loading branch information
gopar authored Dec 27, 2024
2 parents 61540e7 + 27ac528 commit bcfd5e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions elpy-rpc.el
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,21 @@ needed packages from `elpy-rpc--get-package-list'."
(t
(error "Invalid value for `elpy-rpc-virtualenv-path', please set it to a proper value using customize"))))

(defun elpy-rpc--get-pip-dependencies (python-version)
"Return a list of RPC dependencies, based on the current PYTHON-VERSION."
(let*
((basic-py-deps '("jedi" "flake8" "autopep8" "yapf"))
(common-py-deps (cons "black" basic-py-deps))
(modern-py-deps (cons "setuptools" common-py-deps)))

(cond ((version< python-version "3.6") basic-py-deps)
((version< python-version "3.12") common-py-deps)
(t modern-py-deps))))

(defun elpy-rpc--get-package-list ()
"Return the list of packages to be installed in the RPC virtualenv."
(let ((rpc-python-version (elpy-rpc--get-python-version)))
(if (version< rpc-python-version "3.6.0")
'("jedi" "flake8" "autopep8" "yapf")
'("jedi" "flake8" "autopep8" "yapf" "black"))))
(elpy-rpc--get-pip-dependencies rpc-python-version)))

(defun elpy-rpc--get-python-version ()
"Return the RPC python version."
Expand Down
7 changes: 7 additions & 0 deletions test/elpy-rpc--get-pip-dependencies-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;;; -*-coding: utf-8-*-

(ert-deftest elpy-rpc-get-pip-dependencies-should-return-packages-dependent-on-current-python-version ()
(elpy-testcase ()
(should (equal '("jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.5.0")))
(should (equal '("black" "jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.6.0")))
(should (equal '("setuptools" "black" "jedi" "flake8" "autopep8" "yapf") (elpy-rpc--get-pip-dependencies "3.12.0")))))

0 comments on commit bcfd5e8

Please sign in to comment.