Skip to content

Commit ae6812b

Browse files
authored
Pull in pydevd sys.monitoring support (#1680)
This is pulling in @fabioz's latest changes for sys.monitoring and then fixing up any issues found with the debugpy tests. A lot of the changes were made by Fabio since the latest pull from pydevd, so I also created this PR to compare what changes I made to Fabio's baseline: rchiodo/PyDev.Debugger#1 Meaning you really only need to look at that other PR to see what changes I made. The rest of the changes here are from Fabio or ruff doing reformating. After this goes through, we should have sys.monitoring support in debugpy. We can decide later if we want to implement our own support as @int19h started. Fixes #1496
1 parent a2f8081 commit ae6812b

File tree

337 files changed

+136649
-62441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+136649
-62441
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ celerybeat-schedule
8585
*.sage.py
8686

8787
# virtualenv
88-
.venv
88+
.venv*
8989
venv/
9090
ENV/
9191

CONTRIBUTING.md

+27
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,33 @@ The tests are run concurrently, and the default number of workers is 8. You can
9393

9494
While tox is the recommended way to run the test suite, pytest can also be invoked directly from the root of the repository. This requires packages in tests/requirements.txt to be installed first.
9595

96+
#### Keeping logs on test success
97+
98+
There's an internal setting `debugpy_log_passed` that if set to true will not erase the logs after a successful test run. Just search for this in the code and remove the code that deletes the logs on success.
99+
100+
#### Adding logging
101+
102+
Using `pydevd_log.debug` you can add logging just about anywhere in the pydevd code. However this code won't be called if CYTHON support is enabled without recreating the Cython output. To temporarily disable CYTHON support, look for `CYTHON_SUPPORTED` and make sure it's set to False
103+
104+
## Updating pydevd
105+
106+
Pydevd (at src/debugpy/_vendored/pydevd) is a copy of https://github.com/fabioz/PyDev.Debugger. We do not use a git submodule but instead just copy the source.
107+
108+
In order to update the source, you would:
109+
- Sync to the appropriate commit in a pydevd repo
110+
- Diff this against the src/debugpy/_vendored/pydevd folder, being careful to not remove the edits made in the debugpy version
111+
- Run our tests
112+
- Make any fixes to get the tests to pass (see logging on how to debug)
113+
114+
You might need to regenerate the Cython modules after any changes. This can be done by:
115+
116+
- Install Python latest (3.12 as of this writing)
117+
- pip install cython, django>=1.9, setuptools>=0.9, wheel>0.21, twine
118+
- On a windows machine:
119+
- set FORCE_PYDEVD_VC_VARS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
120+
- set PYDEVD_FORCE_BUILD_ALL=True
121+
- in the pydevd folder: python .\build_tools\build.py
122+
96123
## Using modified debugpy in Visual Studio Code
97124
To test integration between debugpy and Visual Studio Code, the latter can be directed to use a custom version of debugpy in lieu of the one bundled with the Python extension. This is done by specifying `"debugAdapterPath"` in `launch.json` - it must point at the root directory of the *package*, which is `src/debugpy` inside the repository:
98125

src/debugpy/_vendored/pydevd/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ snippet.py
3737
build/*
3838
.pytest_cache
3939
/.mypy_cache/
40+
.DS_Store

src/debugpy/_vendored/pydevd/LICENSE-APACHE

-176
This file was deleted.

src/debugpy/_vendored/pydevd/README.md

+56-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,72 @@
1-
PyDev.Debugger
2-
==============
1+
# PyDev.Debugger
2+
3+
4+
## New
5+
6+
Latest `3.x` version: the PyDev debugger now supports `sys.monitoring` which enables
7+
really fast tracing on `Python 3.12` (so, if speed is an issue, make sure you upgrade).
8+
9+
## Important
10+
11+
https://github.com/fabioz/PyDev.Debugger is the main repository
12+
for `pydevd` and the latest versions can always be used directly in:
13+
14+
- [PyDev for Eclipse](http://pydev.org): Enables the usage of `pydevd` in Eclipse (Open Source).
15+
16+
- [Python Debugger (PyDev) for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger): Enables
17+
the usage of `pydevd` in VSCode (note that while `pydevd` itself is open source, this extension is commercial
18+
and helps in the development of the Open Source version. It has a free trial and can be used by acquiring a license for
19+
`PyDev for VSCode` at: https://www.pydev.org/vscode/index.html).
20+
21+
Note that the `Python Debugger (PyDev) for VSCode` may be used as a standalane extension for debugging `Python` by
22+
creating the proper configuration in a `launch.json` and launching it.
23+
24+
Alternatively, [PyDev for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev)
25+
leverages it to offer additional features such as debugging of test cases.
26+
27+
## History / Support
28+
29+
The `PyDev Debugger` (`pydevd` for short) is a **Python debugger** which historically was created to
30+
work with `PyDev` (in Eclipse).
31+
32+
Over the years (as it's open source -- EPL) it was adopted by other IDEs/companies
33+
(so, it was integrated into PyCharm and VSCode Python through `debugpy`, which also bundles `pydevd`).
34+
35+
Note that although it was adopted by other IDEs (and over the years companies of other
36+
commercial IDEs did provide backing), by far most of the work was done without any
37+
external backing and the ongoing work on the project relies on community support.
38+
39+
So, if you like using it, please consider becoming a backer of the project (this is
40+
done through the `PyDev` umbrella, so please see https://www.pydev.org/about.html
41+
for how to contribute to the project).
42+
43+
44+
## Source code / using
345

446
The sources for the PyDev.Debugger may be seen at:
547

648
https://github.com/fabioz/PyDev.Debugger
749

850
In general, the debugger backend should **NOT** be installed separately if you're using an IDE which already
9-
bundles it (such as PyDev, PyCharm or bundled through debugpy, which is the debug adapter used in
10-
VSCode Python and Visual Studio Python).
51+
bundles it (such as [PyDev for Eclipse](http://pydev.org), [Python Debugger (PyDev) for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger),
52+
PyCharm or the Microsoft Python VSCode Extension, which uses `debugpy`, which is another debug adapter bundling `pydevd` to be used in the Microsoft
53+
VSCode Python Extension and Visual Studio Python).
1154

1255
It is however available in PyPi so that it can be installed for doing remote debugging with `pip` -- so, when
1356
debugging a process which runs in another machine, it's possible to `pip install pydevd` and in the code use
14-
`pydevd.settrace(host='10.1.1.1')` to connect the debugger backend to the debugger UI running in the IDE
57+
`pydevd.settrace(host="10.1.1.1")` (in PyDev) or `pydevd.settrace(host="10.1.1.1", protocol="dap")` (in PyDev for VSCode)
58+
to connect the debugger backend to the debugger UI running in the IDE
1559
(whereas previously the sources had to be manually copied from the IDE installation).
1660

17-
`pydevd` is compatible with Python 3.6 onwards.
61+
For instructions on how to `Remote Debug` with `PyDev`, see: https://www.pydev.org/manual_adv_remote_debugger.html
1862

19-
For `Python 2` please keep using `pydevd 2.8.0`.
63+
For instructions on how to `Remote Debug` with `PyDev for VSCode`, see: https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger
64+
65+
`pydevd` is compatible with Python 3.8 onwards and is tested both with CPython as well as PyPy.
2066

21-
`pydevd` is tested both with CPython as well as PyPy.
67+
For `Python 3.3 to 3.7` please keep using `pydevd 2.10.0`.
68+
69+
For `Python 2` please keep using `pydevd 2.8.0`.
2270

2371
Recent versions contain speedup modules using Cython, which are generated with a few changes in the regular files
2472
to `cythonize` the files. To update and compile the cython sources (and generate some other auto-generated files),

0 commit comments

Comments
 (0)