Skip to content

add debugpy-adapter entrypoint - #1870

Merged
Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
TheJJ:adapter-entrypoint
Mar 13, 2025
Merged

Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
TheJJ:adapter-entrypoint

Conversation

@TheJJ

Copy link
Copy Markdown
Contributor

so the adapter can also be launched inside a venv even though debugpy is not installed in the venv.

ref #1868

@TheJJ
Jonas Jelten (TheJJ) requested a review from a team as a code owner March 12, 2025 23:01
@TheJJ

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@rchiodo

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo

Copy link
Copy Markdown
Contributor

Once this goes through we should probably update the wiki page to explain how it can be started:
https://github.com/microsoft/debugpy/wiki/Command-Line-Reference

@TheJJ

Copy link
Copy Markdown
Contributor Author

I don't think the failed ci runs are related to my changes?

@rchiodo

Copy link
Copy Markdown
Contributor

Yeah I agree. I'll submit.

@rchiodo
Rich Chiodo (rchiodo) merged commit 2d220f8 into microsoft:main Mar 13, 2025
@rchiodo

Copy link
Copy Markdown
Contributor

Can you update the wiki with this extra supported command line?

@TheJJ

Copy link
Copy Markdown
Contributor Author

I don't think I have the permissions to edit the wiki? And should the -m debugpy invocations described there also be replaced by the entry-point? I'd of course leave a note that running as module still works.

@rchiodo

Copy link
Copy Markdown
Contributor

I updated all of the command line references to say debugpy now instead.

You added support for calling the adapter directly, right? debugpy-adapter? How would you use that outside of a venv?

With the full path?

C:\Users\<user>\.venv\scripts\debugpy-adapter --listen 5678 foobar.py

@TheJJ

Copy link
Copy Markdown
Contributor Author

No, this doesn't solve the venv-usage yet, I fear, but is a step towards it. What the launcher now allows is launching despite being in a venv (where debugpy isn't installed). What remains to be done is that debugpy now is aware of the venv, I think.

One idea would be adding the venv site package path to the path, and removing system site packages if the venv config disallows system-site-packages.

What do you think?

@rchiodo

Copy link
Copy Markdown
Contributor

Sorry but I'm confused. I thought you were doing the opposite. Debugpy can already be run outside of a venv. It's actually how VS code itself works.

@TheJJ

Copy link
Copy Markdown
Contributor Author

Yes, that's what I'm trying to achieve, but using the adapter. How is debugpy launched in vscode so this works properly?

@rchiodo

Rich Chiodo (rchiodo) commented Mar 18, 2025 •

Copy link
Copy Markdown
Contributor

The command line looks like so:

'c:\Users\rchiodo\AppData\Local\pypoetry\Cache\virtualenvs\single-a0w9Kr8b-py3.11\Scripts\python.exe' 'c:\Users\rchiodo\.vscode\extensions\ms-python.debugpy-2025.4.1-win32-x64\bundled\libs\debugpy\launcher' '52716' '--' 'c:\Users\rchiodo\source\testing\test_move_folders\parent_folder\target_stuff\human.py'

Where

  • c:\Users\rchiodo\AppData\Local\pypoetry\Cache\virtualenvs\single-a0w9Kr8b-py3.11\Scripts\python.exe is my virtual environment
  • c:\Users\rchiodo.vscode\extensions\ms-python.debugpy-2025.4.1-win32-x64\bundled\libs\debugpy\launcher is a python file that ships with the debugpy extension.

That launcher package accomplishes what you're trying to do I believe.

Folke Lemaitre (folke) pushed a commit to LazyVim/LazyVim that referenced this pull request Oct 19, 2025
)

## Description

Uses a less hacky and now officially-supported way of getting the
debugpy DAP adapter path for nvim-dap-python.

Since mfussenegger/nvim-dap-python#184,
nvim-dap-python can start the debugpy adapter using the
`debugpy-adapter` executable. Since
[Mason](https://github.com/mason-org/mason-registry/blob/f7c1c2fde2d1c79f8892dafc9528da1b78b56b25/packages/debugpy/package.yaml#L17)
and [now debugpy itself](microsoft/debugpy#1870)
provide this executable, there's no need to get the `python` executable
from debugpy's venv.

I've gone with just `"debugpy-adapter"` rather than
`LazyVim.get_pkg_path("debugpy", "debugpy-adapter")` so that a
system-wide installation of debugpy can also be used.

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
NanoBoom (NanoBoom) pushed a commit to NanoBoom/LazyVim that referenced this pull request Oct 20, 2025
…080)

## Description

Uses a less hacky and now officially-supported way of getting the
debugpy DAP adapter path for nvim-dap-python.

Since mfussenegger/nvim-dap-python#184,
nvim-dap-python can start the debugpy adapter using the
`debugpy-adapter` executable. Since
[Mason](https://github.com/mason-org/mason-registry/blob/f7c1c2fde2d1c79f8892dafc9528da1b78b56b25/packages/debugpy/package.yaml#L17)
and [now debugpy itself](microsoft/debugpy#1870)
provide this executable, there's no need to get the `python` executable
from debugpy's venv.

I've gone with just `"debugpy-adapter"` rather than
`LazyVim.get_pkg_path("debugpy", "debugpy-adapter")` so that a
system-wide installation of debugpy can also be used.

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants