Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): add support for Python 3.12 and later #2055

Merged

Conversation

DavidVujic
Copy link
Contributor

@DavidVujic DavidVujic commented Dec 27, 2024

PR Summary

In Python 3.12 (and later), the distutils module has been removed. This causes the rpc environment to fail. By installing setuptools as a third-party dependency for Python 3.12 and later, the currently missing dependencies will be added and the elpy Python code will work as expected.

Output from elpy-config for an rpc-venv created with Python 3.12:

There was an unexpected problem starting the RPC process. Please check
the following output to see if this makes sense to you. To me, it
doesn't.

Traceback (most recent call last):
  File "<string>", line 9, in <module>
ModuleNotFoundError: No module named 'distutils'

As an alternative to the changes, there are workarounds such as:

# install setuptools to the elpy rpc-venv manually
~/.emacs.d/elpy/rpc-venv/bin/pip install setuptools 

fixes #2051
fixes #2039
fixes #2033

PR checklist

Please make sure that the following things have been addressed (and check the relevant checkboxes):

  • Commits respect our guidelines
  • Tests are passing properly (see here on how to run Elpy's tests)

NOTE: several tests are failing, also when running them from the master branch (where there are no changes). I have installed cask, created an empty virtual environment, and run the /test/setup script before running the tests.

However, I have run the new unit test I added in this feature branch and verified that it passes.

These tests fails for me in the master branch:

Ran 482 tests in 311.138 seconds
20 unexpected results:
   FAILED  elpy-company-backend-should-add-shell-candidates
   FAILED  elpy-company-backend-should-find-full-prefix-string
   FAILED  elpy-company-backend-should-find-simple-prefix-string
   FAILED  elpy-eldoc-documentation-should-show-object-onelinedoc
   FAILED  elpy-fold-at-point-should-NOT-fold-and-unfold-functions-from-after
   FAILED  elpy-pdb-break-at-point-should-break-at-point
   FAILED  elpy-pdb-debug-buffer-and-break-at-point-should-ignore-breakpoints
   FAILED  elpy-pdb-debug-buffer-from-beginning-should-enter-pdb
   FAILED  elpy-pdb-debug-buffer-should-always-begin-at-first-line
   FAILED  elpy-pdb-debug-buffer-should-continue-with-second-breakpoint
   FAILED  elpy-pdb-debug-buffer-should-enter-pdb
   FAILED  elpy-pdb-debug-buffer-should-forget-previous-breakpoints
   FAILED  elpy-pdb-debug-buffer-should-stop-at-the-first-breakpoint
   FAILED  elpy-pdb-debug-last-exception-should-debug-last-exception
   FAILED  elpy-pdb-debug-last-exception-should-ignore-breakpoints
   FAILED  elpy-pdb-toggle-breakpoint-at-point-should-add-breakpoints
   FAILED  elpy-shell-get-or-create-process-should-add-project-root-to-path
   FAILED  elpy-shell-send-file-should-accept-large-strings
   FAILED  elpy-shell-should-echo-outputs
   FAILED  elpy-should-format-code-with-default-formatter

From the feature branch (same failed tests):

Ran 483 tests in 311.680 seconds
20 unexpected results:
   FAILED  elpy-company-backend-should-add-shell-candidates
   FAILED  elpy-company-backend-should-find-full-prefix-string
   FAILED  elpy-company-backend-should-find-simple-prefix-string
   FAILED  elpy-eldoc-documentation-should-show-object-onelinedoc
   FAILED  elpy-fold-at-point-should-NOT-fold-and-unfold-functions-from-after
   FAILED  elpy-pdb-break-at-point-should-break-at-point
   FAILED  elpy-pdb-debug-buffer-and-break-at-point-should-ignore-breakpoints
   FAILED  elpy-pdb-debug-buffer-from-beginning-should-enter-pdb
   FAILED  elpy-pdb-debug-buffer-should-always-begin-at-first-line
   FAILED  elpy-pdb-debug-buffer-should-continue-with-second-breakpoint
   FAILED  elpy-pdb-debug-buffer-should-enter-pdb
   FAILED  elpy-pdb-debug-buffer-should-forget-previous-breakpoints
   FAILED  elpy-pdb-debug-buffer-should-stop-at-the-first-breakpoint
   FAILED  elpy-pdb-debug-last-exception-should-debug-last-exception
   FAILED  elpy-pdb-debug-last-exception-should-ignore-breakpoints
   FAILED  elpy-pdb-toggle-breakpoint-at-point-should-add-breakpoints
   FAILED  elpy-shell-get-or-create-process-should-add-project-root-to-path
   FAILED  elpy-shell-send-file-should-accept-large-strings
   FAILED  elpy-shell-should-echo-outputs
   FAILED  elpy-should-format-code-with-default-formatter

For new features only:

  • Tests has been added to cover the change
  • The documentation has been updated

…' module has been removed. By installing 'setuptools' the currently missing dependencies will be added
@DavidVujic
Copy link
Contributor Author

Please let me know if I should add or change anything in this Pull Request @gopar @jorgenschaefer.

@gopar gopar merged commit bcfd5e8 into jorgenschaefer:master Dec 27, 2024
0 of 35 checks passed
@gopar
Copy link
Collaborator

gopar commented Dec 27, 2024

Thanks for the PR! \o/

Yeah the tests have been failing for a while. Completely dependent on PR's like these. Thanks again!

@DavidVujic
Copy link
Contributor Author

That's great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants