Skip to content

Pull in pydevd sys.monitoring support #1680

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

Merged
merged 30 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4270df5
Move to latest pydevd
rchiodo Aug 30, 2024
53e7c9b
Add some missing files
rchiodo Aug 30, 2024
135ba7b
Fix test logging
rchiodo Aug 30, 2024
175ab69
Fixed unhandled exceptions
rchiodo Sep 6, 2024
18f0903
Fix extra line events
rchiodo Sep 6, 2024
dc13ec9
Fix enabling monitoring for disconnect
rchiodo Sep 6, 2024
9b4daed
Redirect output seems to work
rchiodo Sep 6, 2024
e768bf6
Fix entry failures
rchiodo Sep 9, 2024
d377954
Fix unwind stopping on same exception as raise
rchiodo Sep 10, 2024
e0f2a1d
Put back the unwind handling we had before
rchiodo Sep 12, 2024
9307cf6
Fix django test failure
rchiodo Sep 12, 2024
0520ffd
Update test failures
rchiodo Sep 12, 2024
d9bed37
Put back Cython and remove unnecessary logging
rchiodo Sep 13, 2024
fbabb61
Regenerate Cython modules
rchiodo Sep 13, 2024
eebeea9
Directions for Cython update
rchiodo Sep 13, 2024
2b70173
Update after linux build
rchiodo Sep 13, 2024
7bd1e4e
Update test failures
rchiodo Sep 13, 2024
b4f19c9
Add back more logging
rchiodo Sep 14, 2024
49dce4e
Get Cython stop exception passing
rchiodo Sep 17, 2024
d128d3b
Fix stop on entry to find <string> file type correctly
rchiodo Sep 17, 2024
120c802
Fix test_breakpoints failures
rchiodo Sep 17, 2024
9a5ff35
Fix stop on entry and breakpoints at the same time
rchiodo Sep 17, 2024
df3db05
Fix django crash
rchiodo Sep 17, 2024
f4a3251
Remove extra logging
rchiodo Sep 17, 2024
ad372a6
Fix safe_repr failures
rchiodo Sep 18, 2024
899898b
Fix numpy test failure
rchiodo Sep 18, 2024
19d6a8d
Update cython output
rchiodo Sep 18, 2024
196fa6f
Remove unnecessary changes
rchiodo Sep 18, 2024
b531385
Remove temp file
rchiodo Sep 18, 2024
c16f07f
Update attach binaries after pr build
rchiodo Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ celerybeat-schedule
*.sage.py

# virtualenv
.venv
.venv*
venv/
ENV/

Expand Down
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,33 @@ The tests are run concurrently, and the default number of workers is 8. You can

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.

#### Keeping logs on test success

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.

#### Adding logging

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

## Updating pydevd

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.

In order to update the source, you would:
- Sync to the appropriate commit in a pydevd repo
- Diff this against the src/debugpy/_vendored/pydevd folder, being careful to not remove the edits made in the debugpy version
- Run our tests
- Make any fixes to get the tests to pass (see logging on how to debug)

You might need to regenerate the Cython modules after any changes. This can be done by:

- Install Python latest (3.12 as of this writing)
- pip install cython, django>=1.9, setuptools>=0.9, wheel>0.21, twine
- On a windows machine:
- set FORCE_PYDEVD_VC_VARS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
- set PYDEVD_FORCE_BUILD_ALL=True
- in the pydevd folder: python .\build_tools\build.py

## Using modified debugpy in Visual Studio Code
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:

Expand Down
1 change: 1 addition & 0 deletions src/debugpy/_vendored/pydevd/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ snippet.py
build/*
.pytest_cache
/.mypy_cache/
.DS_Store
176 changes: 0 additions & 176 deletions src/debugpy/_vendored/pydevd/LICENSE-APACHE

This file was deleted.

64 changes: 56 additions & 8 deletions src/debugpy/_vendored/pydevd/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,72 @@
PyDev.Debugger
==============
# PyDev.Debugger


## New

Latest `3.x` version: the PyDev debugger now supports `sys.monitoring` which enables
really fast tracing on `Python 3.12` (so, if speed is an issue, make sure you upgrade).

## Important

https://github.com/fabioz/PyDev.Debugger is the main repository
for `pydevd` and the latest versions can always be used directly in:

- [PyDev for Eclipse](http://pydev.org): Enables the usage of `pydevd` in Eclipse (Open Source).

- [Python Debugger (PyDev) for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger): Enables
the usage of `pydevd` in VSCode (note that while `pydevd` itself is open source, this extension is commercial
and helps in the development of the Open Source version. It has a free trial and can be used by acquiring a license for
`PyDev for VSCode` at: https://www.pydev.org/vscode/index.html).

Note that the `Python Debugger (PyDev) for VSCode` may be used as a standalane extension for debugging `Python` by
creating the proper configuration in a `launch.json` and launching it.

Alternatively, [PyDev for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev)
leverages it to offer additional features such as debugging of test cases.

## History / Support

The `PyDev Debugger` (`pydevd` for short) is a **Python debugger** which historically was created to
work with `PyDev` (in Eclipse).

Over the years (as it's open source -- EPL) it was adopted by other IDEs/companies
(so, it was integrated into PyCharm and VSCode Python through `debugpy`, which also bundles `pydevd`).

Note that although it was adopted by other IDEs (and over the years companies of other
commercial IDEs did provide backing), by far most of the work was done without any
external backing and the ongoing work on the project relies on community support.

So, if you like using it, please consider becoming a backer of the project (this is
done through the `PyDev` umbrella, so please see https://www.pydev.org/about.html
for how to contribute to the project).


## Source code / using

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

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

In general, the debugger backend should **NOT** be installed separately if you're using an IDE which already
bundles it (such as PyDev, PyCharm or bundled through debugpy, which is the debug adapter used in
VSCode Python and Visual Studio Python).
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),
PyCharm or the Microsoft Python VSCode Extension, which uses `debugpy`, which is another debug adapter bundling `pydevd` to be used in the Microsoft
VSCode Python Extension and Visual Studio Python).

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

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

For `Python 2` please keep using `pydevd 2.8.0`.
For instructions on how to `Remote Debug` with `PyDev for VSCode`, see: https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger

`pydevd` is compatible with Python 3.8 onwards and is tested both with CPython as well as PyPy.

`pydevd` is tested both with CPython as well as PyPy.
For `Python 3.3 to 3.7` please keep using `pydevd 2.10.0`.

For `Python 2` please keep using `pydevd 2.8.0`.

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