Skip to content

Conversation

@TheJJ
Copy link
Contributor

@TheJJ TheJJ commented Mar 12, 2025

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

ref #1868

@TheJJ TheJJ requested a review from a team as a code owner March 12, 2025 23:01
@TheJJ
Copy link
Contributor Author

TheJJ commented Mar 12, 2025

@microsoft-github-policy-service agree

@rchiodo
Copy link
Contributor

rchiodo commented Mar 12, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rchiodo
Copy link
Contributor

rchiodo commented Mar 12, 2025

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
Contributor Author

TheJJ commented Mar 13, 2025

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

@rchiodo
Copy link
Contributor

rchiodo commented Mar 13, 2025

Yeah I agree. I'll submit.

@rchiodo rchiodo merged commit 2d220f8 into microsoft:main Mar 13, 2025
21 of 24 checks passed
@rchiodo
Copy link
Contributor

rchiodo commented Mar 13, 2025

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

@TheJJ
Copy link
Contributor Author

TheJJ commented Mar 13, 2025

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
Contributor

rchiodo commented Mar 13, 2025

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
Contributor Author

TheJJ commented Mar 15, 2025

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
Contributor

rchiodo commented Mar 17, 2025

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
Contributor Author

TheJJ commented Mar 18, 2025

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

@rchiodo
Copy link
Contributor

rchiodo commented Mar 18, 2025

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 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 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