diff --git a/setup.py b/setup.py index 0bb4f00ca..15e48f4d5 100644 --- a/setup.py +++ b/setup.py @@ -176,7 +176,14 @@ def tail_is(*suffixes): "License :: OSI Approved :: MIT License", ], package_dir={"": "src"}, - packages=setuptools.find_namespace_packages(where="src", include=["debugpy*"]), + packages=[ + "debugpy", + "debugpy.adapter", + "debugpy.common", + "debugpy.launcher", + "debugpy.server", + "debugpy._vendored", + ], package_data={ "debugpy": ["ThirdPartyNotices.txt"], "debugpy._vendored": [ diff --git a/src/debugpy/_vendored/pydevd/pydevd_plugins/__init__.py b/src/debugpy/_vendored/pydevd/pydevd_plugins/__init__.py new file mode 100644 index 000000000..bb61062c9 --- /dev/null +++ b/src/debugpy/_vendored/pydevd/pydevd_plugins/__init__.py @@ -0,0 +1,2 @@ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/__init__.py b/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/__init__.py new file mode 100644 index 000000000..bb61062c9 --- /dev/null +++ b/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/__init__.py @@ -0,0 +1,2 @@ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/__init__.py b/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/__init__.py new file mode 100644 index 000000000..bb61062c9 --- /dev/null +++ b/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types/__init__.py @@ -0,0 +1,2 @@ +import pkgutil +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/tests/debugpy/test_numpy.py b/tests/debugpy/test_numpy.py new file mode 100644 index 000000000..aa70a19e3 --- /dev/null +++ b/tests/debugpy/test_numpy.py @@ -0,0 +1,77 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See LICENSE in the project root +# for license information. + +from tests import debug +from tests.patterns import some + + +def test_ndarray(pyfile, target, run): + @pyfile + def code_to_debug(): + import numpy + import debuggee + + debuggee.setup() + a = numpy.array([123, 456], numpy.int32) + print(a) # @bp + + with debug.Session() as session: + session.config["variablePresentation"] = {"all": "hide", "protected": "inline"} + with run(session, target(code_to_debug)): + session.set_breakpoints(code_to_debug, all) + + stop = session.wait_for_stop() + scopes = session.request("scopes", {"frameId": stop.frame_id})["scopes"] + globals_ref = scopes[0]["variablesReference"] + vars = session.request( + "variables", + {"variablesReference": globals_ref}, + )["variables"] + print(vars) + + # Fetch children variables of the array. + (a,) = (v for v in vars if v["name"] == "a") + a_vars = session.request( + "variables", + {"variablesReference": a["variablesReference"]}, + )["variables"] + print(a_vars) + + # Fetch the actual array items + (items,) = (v for v in a_vars if v["name"] == "[0:2] ") + a_items = session.request( + "variables", + {"variablesReference": items["variablesReference"]}, + )["variables"] + print(a_items) + + assert a_items == [ + some.dict.containing( + { + "type": "int32", + "name": "0", + "value": "123", + "variablesReference": some.int, + } + ), + some.dict.containing( + { + "type": "int32", + "name": "1", + "value": "456", + "variablesReference": some.int, + } + ), + some.dict.containing( + { + "type": "int", + "name": "len()", + "value": "2", + "presentationHint": {"attributes": ["readOnly"]}, + "variablesReference": 0, + } + ), + ] + + session.request_continue() diff --git a/tests/requirements.txt b/tests/requirements.txt index f6678ce61..12784fe35 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -13,6 +13,7 @@ psutil ## Used in Python code that is run/debugged by the tests: django -requests -gevent flask +gevent +numpy +requests