2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
pythonOlder,
|
2024-07-27 06:49:29 +00:00
|
|
|
pythonAtLeast,
|
2024-06-05 15:53:02 +00:00
|
|
|
fetchFromGitHub,
|
|
|
|
substituteAll,
|
|
|
|
gdb,
|
|
|
|
lldb,
|
|
|
|
pytestCheckHook,
|
|
|
|
pytest-xdist,
|
|
|
|
pytest-timeout,
|
|
|
|
importlib-metadata,
|
|
|
|
psutil,
|
|
|
|
django,
|
|
|
|
requests,
|
|
|
|
gevent,
|
|
|
|
numpy,
|
|
|
|
flask,
|
2020-07-18 16:06:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "debugpy";
|
2024-10-04 16:56:33 +00:00
|
|
|
version = "1.8.6";
|
2022-01-13 20:06:32 +00:00
|
|
|
format = "setuptools";
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
disabled = pythonOlder "3.8";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-02-02 18:25:31 +00:00
|
|
|
owner = "microsoft";
|
|
|
|
repo = "debugpy";
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-10-04 16:56:33 +00:00
|
|
|
hash = "sha256-kkFNIJ3QwojwgiRAOmBiWIg5desxOKTmo9YH1Qup6fI=";
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
patches =
|
|
|
|
[
|
|
|
|
# Use nixpkgs version instead of versioneer
|
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-version.patch;
|
|
|
|
inherit version;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Fix importing debugpy in:
|
|
|
|
# - test_nodebug[module-launch(externalTerminal)]
|
|
|
|
# - test_nodebug[module-launch(integratedTerminal)]
|
|
|
|
#
|
|
|
|
# NOTE: The import failures seen in these tests without the patch
|
|
|
|
# will be seen if a user "installs" debugpy by adding it to PYTHONPATH.
|
|
|
|
# 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
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
2024-06-05 15:53:02 +00:00
|
|
|
# Hard code GDB path (used to attach to process)
|
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-gdb.patch;
|
|
|
|
inherit gdb;
|
|
|
|
})
|
|
|
|
]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-06-05 15:53:02 +00:00
|
|
|
# Hard code LLDB path (used to attach to process)
|
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-lldb.patch;
|
|
|
|
inherit lldb;
|
|
|
|
})
|
|
|
|
];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
|
|
|
# Remove pre-compiled "attach" libraries and recompile for host platform
|
|
|
|
# Compile flags taken from linux_and_mac/compile_linux.sh & linux_and_mac/compile_mac.sh
|
2024-06-05 15:53:02 +00:00
|
|
|
preBuild = ''
|
|
|
|
(
|
|
|
|
set -x
|
|
|
|
cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process
|
|
|
|
rm *.so *.dylib *.dll *.exe *.pdb
|
|
|
|
$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" = "-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}")
|
|
|
|
}
|
|
|
|
)'';
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# Disable tests for unmaintained versions of python
|
|
|
|
doCheck = pythonAtLeast "3.11";
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2024-04-21 15:54:59 +00:00
|
|
|
## 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:
|
2021-10-17 09:34:42 +00:00
|
|
|
django
|
2020-10-07 09:15:18 +00:00
|
|
|
flask
|
2021-10-17 09:34:42 +00:00
|
|
|
gevent
|
2024-04-21 15:54:59 +00:00
|
|
|
numpy
|
2020-10-07 09:15:18 +00:00
|
|
|
requests
|
2020-07-18 16:06:22 +00:00
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
preCheck =
|
|
|
|
''
|
|
|
|
export DEBUGPY_PROCESS_SPAWN_TIMEOUT=0
|
|
|
|
export DEBUGPY_PROCESS_EXIT_TIMEOUT=0
|
|
|
|
''
|
2024-09-26 11:04:55 +00:00
|
|
|
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
2024-06-05 15:53:02 +00:00
|
|
|
# https://github.com/python/cpython/issues/74570#issuecomment-1093748531
|
|
|
|
export no_proxy='*';
|
|
|
|
'';
|
2022-10-06 18:32:54 +00:00
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
postCheck = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
2022-10-06 18:32:54 +00:00
|
|
|
unset no_proxy
|
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
# Override default arguments in pytest.ini
|
2024-06-05 15:53:02 +00:00
|
|
|
pytestFlagsArray = [ "--timeout=0" ];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Fixes hanging tests on Darwin
|
|
|
|
__darwinAllowLocalNetworking = true;
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "debugpy" ];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Implementation of the Debug Adapter Protocol for Python";
|
2020-07-18 16:06:22 +00:00
|
|
|
homepage = "https://github.com/microsoft/debugpy";
|
2022-12-02 08:20:57 +00:00
|
|
|
changelog = "https://github.com/microsoft/debugpy/releases/tag/v${version}";
|
2020-07-18 16:06:22 +00:00
|
|
|
license = licenses.mit;
|
2021-05-28 09:39:13 +00:00
|
|
|
maintainers = with maintainers; [ kira-bruneau ];
|
2024-06-05 15:53:02 +00:00
|
|
|
platforms = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"i686-darwin"
|
|
|
|
"aarch64-darwin"
|
|
|
|
];
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
}
|