diff --git a/pkgs/development/python-modules/debugpy/default.nix b/pkgs/development/python-modules/debugpy/default.nix index 8a01afb3c73b..4ba770e251c6 100644 --- a/pkgs/development/python-modules/debugpy/default.nix +++ b/pkgs/development/python-modules/debugpy/default.nix @@ -5,15 +5,17 @@ , fetchFromGitHub , substituteAll , gdb -, django -, flask -, gevent -, psutil -, pytest-timeout -, pytest-xdist +, lldb , pytestCheckHook +, pytest-xdist +, pytest-timeout +, importlib-metadata +, psutil +, django , requests -, llvmPackages +, gevent +, numpy +, flask }: buildPythonPackage rec { @@ -21,7 +23,7 @@ buildPythonPackage rec { version = "1.8.1"; format = "setuptools"; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.8"; src = fetchFromGitHub { owner = "microsoft"; @@ -46,6 +48,12 @@ buildPythonPackage rec { # To avoid this issue, debugpy should be installed using python.withPackages: # python.withPackages (ps: with ps; [ debugpy ]) ./fix-test-pythonpath.patch + + # Attach pid tests are disabled by default on windows & macos, + # but are also flaky on linux: + # - https://github.com/NixOS/nixpkgs/issues/262000 + # - https://github.com/NixOS/nixpkgs/issues/251045 + ./skip-attach-pid-tests.patch ] ++ lib.optionals stdenv.isLinux [ # Hard code GDB path (used to attach to process) (substituteAll { @@ -56,7 +64,7 @@ buildPythonPackage rec { # Hard code LLDB path (used to attach to process) (substituteAll { src = ./hardcode-lldb.patch; - inherit (llvmPackages) lldb; + inherit lldb; }) ]; @@ -66,24 +74,31 @@ buildPythonPackage rec { set -x cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process rm *.so *.dylib *.dll *.exe *.pdb - ${stdenv.cc}/bin/c++ linux_and_mac/attach.cpp -Ilinux_and_mac -fPIC -nostartfiles ${{ + $CXX linux_and_mac/attach.cpp -Ilinux_and_mac -std=c++11 -fPIC -nostartfiles ${{ "x86_64-linux" = "-shared -o attach_linux_amd64.so"; "i686-linux" = "-shared -o attach_linux_x86.so"; "aarch64-linux" = "-shared -o attach_linux_arm64.so"; - "x86_64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_x86_64.dylib"; - "i686-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_x86.dylib"; - "aarch64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_arm64.dylib"; + "x86_64-darwin" = "-D_REENTRANT -dynamiclib -lc -o attach_x86_64.dylib"; + "i686-darwin" = "-D_REENTRANT -dynamiclib -lc -o attach_x86.dylib"; + "aarch64-darwin" = "-D_REENTRANT -dynamiclib -lc -o attach_arm64.dylib"; }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}")} )''; nativeCheckInputs = [ + ## Used to run the tests: + pytestCheckHook + pytest-xdist + pytest-timeout + + ## Used by test helpers: + importlib-metadata + psutil + + ## Used in Python code that is run/debugged by the tests: django flask gevent - psutil - pytest-timeout - pytest-xdist - pytestCheckHook + numpy requests ]; @@ -107,13 +122,6 @@ buildPythonPackage rec { # Fixes hanging tests on Darwin __darwinAllowLocalNetworking = true; - disabledTests = [ - # testsuite gets stuck at this one - "test_attach_pid_client" - ]; - # TODO? https://github.com/NixOS/nixpkgs/issues/262000 - doCheck = !stdenv.isLinux; - pythonImportsCheck = [ "debugpy" ]; diff --git a/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch b/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch index 7cfb1a49ec38..e368357d5cc2 100644 --- a/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch +++ b/pkgs/development/python-modules/debugpy/fix-test-pythonpath.patch @@ -1,12 +1,12 @@ diff --git a/tests/debug/session.py b/tests/debug/session.py -index 7dacc1f9..f303e20a 100644 +index d0921956..459c89c0 100644 --- a/tests/debug/session.py +++ b/tests/debug/session.py -@@ -631,6 +631,7 @@ class Session(object): +@@ -704,6 +704,7 @@ class Session(object): if "PYTHONPATH" in self.config.env: # If specified, launcher will use it in lieu of PYTHONPATH it inherited # from the adapter when spawning debuggee, so we need to adjust again. + self.config.env.prepend_to("PYTHONPATH", os.environ["PYTHONPATH"]) self.config.env.prepend_to("PYTHONPATH", DEBUGGEE_PYTHONPATH.strpath) - return self._request_start("launch") + # Adapter is going to start listening for server and spawn the launcher at diff --git a/pkgs/development/python-modules/debugpy/hardcode-gdb.patch b/pkgs/development/python-modules/debugpy/hardcode-gdb.patch index 2fe09a70151a..5cc68b21b3c6 100644 --- a/pkgs/development/python-modules/debugpy/hardcode-gdb.patch +++ b/pkgs/development/python-modules/debugpy/hardcode-gdb.patch @@ -1,8 +1,8 @@ diff --git a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py -index ed43e370..d3d6669a 100644 +index 85f3353b..56fab577 100644 --- a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py +++ b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py -@@ -404,7 +404,7 @@ def run_python_code_linux(pid, python_code, connect_debugger_tracing=False, show +@@ -410,7 +410,7 @@ def run_python_code_linux(pid, python_code, connect_debugger_tracing=False, show is_debug = 0 # Note that the space in the beginning of each line in the multi-line is important! cmd = [ diff --git a/pkgs/development/python-modules/debugpy/hardcode-lldb.patch b/pkgs/development/python-modules/debugpy/hardcode-lldb.patch index 3a1013187351..215e7ee0f9ca 100644 --- a/pkgs/development/python-modules/debugpy/hardcode-lldb.patch +++ b/pkgs/development/python-modules/debugpy/hardcode-lldb.patch @@ -1,8 +1,8 @@ diff --git a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py -index d3d6669a..2ded8d9c 100644 +index 56fab577..989ede03 100644 --- a/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py +++ b/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py -@@ -494,7 +494,7 @@ def run_python_code_mac(pid, python_code, connect_debugger_tracing=False, show_d +@@ -500,7 +500,7 @@ def run_python_code_mac(pid, python_code, connect_debugger_tracing=False, show_d is_debug = 0 # Note that the space in the beginning of each line in the multi-line is important! cmd = [ diff --git a/pkgs/development/python-modules/debugpy/hardcode-version.patch b/pkgs/development/python-modules/debugpy/hardcode-version.patch index 11d565b98060..9fa42a0605f8 100644 --- a/pkgs/development/python-modules/debugpy/hardcode-version.patch +++ b/pkgs/development/python-modules/debugpy/hardcode-version.patch @@ -1,5 +1,5 @@ diff --git a/setup.py b/setup.py -index 3abc811b..91354604 100644 +index 1bfba237..414bb4d5 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,6 @@ import sys diff --git a/pkgs/development/python-modules/debugpy/skip-attach-pid-tests.patch b/pkgs/development/python-modules/debugpy/skip-attach-pid-tests.patch new file mode 100644 index 000000000000..a993940f7266 --- /dev/null +++ b/pkgs/development/python-modules/debugpy/skip-attach-pid-tests.patch @@ -0,0 +1,27 @@ +diff --git a/tests/debug/runners.py b/tests/debug/runners.py +index dc60d0ae..cf4a06a3 100644 +--- a/tests/debug/runners.py ++++ b/tests/debug/runners.py +@@ -163,7 +163,7 @@ def _attach_common_config(session, target, cwd): + @_runner + @contextlib.contextmanager + def attach_pid(session, target, cwd=None, wait=True): +- if wait and not sys.platform.startswith("linux"): ++ if wait: + pytest.skip("https://github.com/microsoft/ptvsd/issues/1926") + + log.info("Attaching {0} to {1} by PID.", session, target) +diff --git a/tests/debugpy/test_attach.py b/tests/debugpy/test_attach.py +index afabc1ac..2fff3982 100644 +--- a/tests/debugpy/test_attach.py ++++ b/tests/debugpy/test_attach.py +@@ -151,8 +151,7 @@ def test_reattach(pyfile, target, run): + + + @pytest.mark.parametrize("pid_type", ["int", "str"]) +-@pytest.mark.skipif( +- not sys.platform.startswith("linux"), ++@pytest.mark.skip( + reason="https://github.com/microsoft/debugpy/issues/311", + ) + def test_attach_pid_client(pyfile, target, pid_type):