2020-08-12 03:59:39 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, substituteAll
|
|
|
|
, gdb
|
2021-10-16 05:52:32 +01:00
|
|
|
, django
|
2020-08-12 03:59:39 +01:00
|
|
|
, flask
|
2021-10-16 05:52:32 +01:00
|
|
|
, gevent
|
2020-08-12 03:59:39 +01:00
|
|
|
, psutil
|
|
|
|
, pytest-timeout
|
2021-07-20 22:08:56 +01:00
|
|
|
, pytest-xdist
|
2020-08-12 03:59:39 +01:00
|
|
|
, pytestCheckHook
|
|
|
|
, requests
|
2021-10-16 05:52:32 +01:00
|
|
|
, isPy3k
|
2020-06-06 23:06:28 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "debugpy";
|
2021-10-24 18:02:08 +01:00
|
|
|
version = "1.5.1";
|
2020-06-06 23:06:28 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Microsoft";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-10-24 18:02:08 +01:00
|
|
|
sha256 = "sha256-dPP4stLt5nl9B9afPmH6/hpGKXBsaTpvYZQSHxU6KaY=";
|
2020-06-06 23:06:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Hard code GDB path (used to attach to process)
|
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-gdb.patch;
|
|
|
|
inherit gdb;
|
|
|
|
})
|
|
|
|
|
2021-05-05 00:18:39 +01:00
|
|
|
# Use nixpkgs version instead of versioneer
|
2020-11-18 01:50:06 +00:00
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-version.patch;
|
|
|
|
inherit version;
|
|
|
|
})
|
|
|
|
|
2020-06-06 23:06:28 +01:00
|
|
|
# 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
|
|
|
|
];
|
|
|
|
|
|
|
|
# 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
|
|
|
|
preBuild = ''(
|
|
|
|
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 ${{
|
2021-08-10 22:10:38 +01:00
|
|
|
"x86_64-linux" = "-shared -m64 -o attach_linux_amd64.so";
|
|
|
|
"i686-linux" = "-shared -m32 -o attach_linux_x86.so";
|
2021-11-30 20:57:50 +00:00
|
|
|
"aarch64-linux" = "-shared -o attach_linux_arm64.so";
|
2021-08-10 22:10:38 +01:00
|
|
|
"x86_64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch x86_64 -o attach_x86_64.dylib";
|
|
|
|
"i686-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch i386 -o attach_x86.dylib";
|
|
|
|
"aarch64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch arm64 -o attach_arm64.dylib";
|
2021-08-29 21:32:19 +01:00
|
|
|
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}")}
|
2020-06-06 23:06:28 +01:00
|
|
|
)'';
|
|
|
|
|
2021-10-16 05:52:32 +01:00
|
|
|
doCheck = isPy3k;
|
2020-06-06 23:06:28 +01:00
|
|
|
checkInputs = [
|
2021-10-16 05:52:32 +01:00
|
|
|
django
|
2020-08-12 03:59:39 +01:00
|
|
|
flask
|
2021-10-16 05:52:32 +01:00
|
|
|
gevent
|
2020-08-12 03:59:39 +01:00
|
|
|
psutil
|
|
|
|
pytest-timeout
|
2021-07-20 22:08:56 +01:00
|
|
|
pytest-xdist
|
2020-08-12 03:59:39 +01:00
|
|
|
pytestCheckHook
|
|
|
|
requests
|
2020-06-06 23:06:28 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# Override default arguments in pytest.ini
|
2020-08-12 03:59:39 +01:00
|
|
|
pytestFlagsArray = [ "--timeout=0" "-n=$NIX_BUILD_CORES" ];
|
2020-06-06 23:06:28 +01:00
|
|
|
|
2021-05-05 00:18:39 +01:00
|
|
|
pythonImportsCheck = [ "debugpy" ];
|
|
|
|
|
2020-08-12 03:59:39 +01:00
|
|
|
meta = with lib; {
|
2020-06-06 23:06:28 +01:00
|
|
|
description = "An implementation of the Debug Adapter Protocol for Python";
|
|
|
|
homepage = "https://github.com/microsoft/debugpy";
|
|
|
|
license = licenses.mit;
|
2021-05-22 15:47:40 +01:00
|
|
|
maintainers = with maintainers; [ kira-bruneau ];
|
2021-11-30 20:57:50 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "i686-darwin" "aarch64-darwin" ];
|
2020-06-06 23:06:28 +01:00
|
|
|
};
|
|
|
|
}
|