linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / python-modules / debugpy / default.nix
blobbeb5ba9c46b73e2c68caf968b1c56d0447204c3d
1 { lib
2 , stdenv
3 , buildPythonPackage
4 , fetchFromGitHub
5 , substituteAll
6 , gdb
7 , flask
8 , psutil
9 , pytest-timeout
10 , pytest_xdist
11 , pytestCheckHook
12 , requests
13 , isPy27
14 , django
15 , gevent
18 buildPythonPackage rec {
19   pname = "debugpy";
20   version = "1.2.1";
22   src = fetchFromGitHub {
23     owner = "Microsoft";
24     repo = pname;
25     rev = "v${version}";
26     sha256 = "1dgjbbhy228w2zbfq5pf0hkai7742zw8mmybnzjdc9l6pw7360rq";
27   };
29   patches = [
30     # Hard code GDB path (used to attach to process)
31     (substituteAll {
32       src = ./hardcode-gdb.patch;
33       inherit gdb;
34     })
36     (substituteAll {
37       src = ./hardcode-version.patch;
38       inherit version;
39     })
41     # Fix importing debugpy in:
42     # - test_nodebug[module-launch(externalTerminal)]
43     # - test_nodebug[module-launch(integratedTerminal)]
44     #
45     # NOTE: The import failures seen in these tests without the patch
46     # will be seen if a user "installs" debugpy by adding it to PYTHONPATH.
47     # To avoid this issue, debugpy should be installed using python.withPackages:
48     # python.withPackages (ps: with ps; [ debugpy ])
49     ./fix-test-pythonpath.patch
50   ];
52   # Remove pre-compiled "attach" libraries and recompile for host platform
53   # Compile flags taken from linux_and_mac/compile_linux.sh & linux_and_mac/compile_mac.sh
54   preBuild = ''(
55     set -x
56     cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process
57     rm *.so *.dylib *.dll *.exe *.pdb
58     ${stdenv.cc}/bin/c++ linux_and_mac/attach.cpp -Ilinux_and_mac -fPIC -nostartfiles ${{
59       "x86_64-linux"  = "-shared -m64 -o attach_linux_amd64.so";
60       "i686-linux"    = "-shared -m32 -o attach_linux_x86.so";
61       "x86_64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch x86_64 -o attach_x86_64.dylib";
62       "i686-darwin"   = "-std=c++11 -lc -D_REENTRANT -dynamiclib -arch i386 -o attach_x86.dylib";
63     }.${stdenv.hostPlatform.system}}
64   )'';
66   checkInputs = [
67     flask
68     psutil
69     pytest-timeout
70     pytest_xdist
71     pytestCheckHook
72     requests
73   ] ++ lib.optionals (!isPy27) [
74     django
75     gevent
76   ];
78   # Override default arguments in pytest.ini
79   pytestFlagsArray = [ "--timeout=0" "-n=$NIX_BUILD_CORES" ];
81   disabledTests = lib.optionals isPy27 [
82     # django 1.11 is the last version to support Python 2.7
83     # and is no longer built in nixpkgs
84     "django"
86     # gevent fails to import zope.interface with Python 2.7
87     "gevent"
88   ];
90   meta = with lib; {
91     description = "An implementation of the Debug Adapter Protocol for Python";
92     homepage = "https://github.com/microsoft/debugpy";
93     license = licenses.mit;
94     maintainers = with maintainers; [ metadark ];
95     platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "i686-darwin" ];
96   };