2020-10-07 09:15:18 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2021-06-28 23:13:55 +00:00
|
|
|
, fetchpatch
|
2020-10-07 09:15:18 +00:00
|
|
|
, substituteAll
|
|
|
|
, gdb
|
|
|
|
, flask
|
|
|
|
, psutil
|
|
|
|
, pytest-timeout
|
2021-07-24 12:14:16 +00:00
|
|
|
, pytest-xdist
|
2020-10-07 09:15:18 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, requests
|
2020-07-18 16:06:22 +00:00
|
|
|
, isPy27
|
2020-10-07 09:15:18 +00:00
|
|
|
, django
|
|
|
|
, gevent
|
2020-07-18 16:06:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "debugpy";
|
2021-05-20 23:08:51 +00:00
|
|
|
version = "1.3.0";
|
2020-07-18 16:06:22 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Microsoft";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-05-20 23:08:51 +00:00
|
|
|
hash = "sha256-YGzc9mMIzPTmUgIXuZROLdYKjUm69x9SR+JtYRVpn24=";
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Hard code GDB path (used to attach to process)
|
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-gdb.patch;
|
|
|
|
inherit gdb;
|
|
|
|
})
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
# Use nixpkgs version instead of versioneer
|
2020-11-21 19:51:51 +00:00
|
|
|
(substituteAll {
|
|
|
|
src = ./hardcode-version.patch;
|
|
|
|
inherit version;
|
|
|
|
})
|
|
|
|
|
2020-07-18 16:06:22 +00: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
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
# Fix tests with flask>=2.0
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/microsoft/debugpy/commit/0a7f2cd67dda27ea4d38389b49a4e2a1899b834e.patch";
|
|
|
|
sha256 = "1g070fn07n7jj01jaf5s570zn70akf6klkamigs3ix11gh736rpn";
|
|
|
|
})
|
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
|
|
|
|
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 ${{
|
|
|
|
"x86_64-linux" = "-shared -m64 -o attach_linux_amd64.so";
|
|
|
|
"i686-linux" = "-shared -m32 -o attach_linux_x86.so";
|
|
|
|
"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";
|
|
|
|
}.${stdenv.hostPlatform.system}}
|
|
|
|
)'';
|
|
|
|
|
|
|
|
checkInputs = [
|
2020-10-07 09:15:18 +00:00
|
|
|
flask
|
|
|
|
psutil
|
|
|
|
pytest-timeout
|
2021-07-24 12:14:16 +00:00
|
|
|
pytest-xdist
|
2020-10-07 09:15:18 +00:00
|
|
|
pytestCheckHook
|
|
|
|
requests
|
|
|
|
] ++ lib.optionals (!isPy27) [
|
|
|
|
django
|
|
|
|
gevent
|
2020-07-18 16:06:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Override default arguments in pytest.ini
|
2020-10-07 09:15:18 +00:00
|
|
|
pytestFlagsArray = [ "--timeout=0" "-n=$NIX_BUILD_CORES" ];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
disabledTests = lib.optionals isPy27 [
|
|
|
|
# django 1.11 is the last version to support Python 2.7
|
|
|
|
# and is no longer built in nixpkgs
|
|
|
|
"django"
|
|
|
|
|
|
|
|
# gevent fails to import zope.interface with Python 2.7
|
|
|
|
"gevent"
|
|
|
|
];
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
pythonImportsCheck = [ "debugpy" ];
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
meta = with lib; {
|
2020-07-18 16:06:22 +00:00
|
|
|
description = "An implementation of the Debug Adapter Protocol for Python";
|
|
|
|
homepage = "https://github.com/microsoft/debugpy";
|
|
|
|
license = licenses.mit;
|
2021-05-28 09:39:13 +00:00
|
|
|
maintainers = with maintainers; [ kira-bruneau ];
|
2020-07-18 16:06:22 +00:00
|
|
|
platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "i686-darwin" ];
|
|
|
|
};
|
|
|
|
}
|