at 24.05-pre 3.7 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, pythonOlder 5, fetchFromGitHub 6, substituteAll 7, gdb 8, django 9, flask 10, gevent 11, psutil 12, pytest-timeout 13, pytest-xdist 14, pytestCheckHook 15, requests 16, llvmPackages 17}: 18 19buildPythonPackage rec { 20 pname = "debugpy"; 21 version = "1.8.0"; 22 format = "setuptools"; 23 24 disabled = pythonOlder "3.7"; 25 26 src = fetchFromGitHub { 27 owner = "microsoft"; 28 repo = "debugpy"; 29 rev = "refs/tags/v${version}"; 30 hash = "sha256-FW1RDmj4sDBS0q08C82ErUd16ofxJxgVaxfykn/wVBA="; 31 }; 32 33 patches = [ 34 # Use nixpkgs version instead of versioneer 35 (substituteAll { 36 src = ./hardcode-version.patch; 37 inherit version; 38 }) 39 40 # Fix importing debugpy in: 41 # - test_nodebug[module-launch(externalTerminal)] 42 # - test_nodebug[module-launch(integratedTerminal)] 43 # 44 # NOTE: The import failures seen in these tests without the patch 45 # will be seen if a user "installs" debugpy by adding it to PYTHONPATH. 46 # To avoid this issue, debugpy should be installed using python.withPackages: 47 # python.withPackages (ps: with ps; [ debugpy ]) 48 ./fix-test-pythonpath.patch 49 ] ++ lib.optionals stdenv.isLinux [ 50 # Hard code GDB path (used to attach to process) 51 (substituteAll { 52 src = ./hardcode-gdb.patch; 53 inherit gdb; 54 }) 55 ] ++ lib.optionals stdenv.isDarwin [ 56 # Hard code LLDB path (used to attach to process) 57 (substituteAll { 58 src = ./hardcode-lldb.patch; 59 inherit (llvmPackages) lldb; 60 }) 61 ]; 62 63 # Remove pre-compiled "attach" libraries and recompile for host platform 64 # Compile flags taken from linux_and_mac/compile_linux.sh & linux_and_mac/compile_mac.sh 65 preBuild = ''( 66 set -x 67 cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process 68 rm *.so *.dylib *.dll *.exe *.pdb 69 ${stdenv.cc}/bin/c++ linux_and_mac/attach.cpp -Ilinux_and_mac -fPIC -nostartfiles ${{ 70 "x86_64-linux" = "-shared -o attach_linux_amd64.so"; 71 "i686-linux" = "-shared -o attach_linux_x86.so"; 72 "aarch64-linux" = "-shared -o attach_linux_arm64.so"; 73 "x86_64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_x86_64.dylib"; 74 "i686-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_x86.dylib"; 75 "aarch64-darwin" = "-std=c++11 -lc -D_REENTRANT -dynamiclib -o attach_arm64.dylib"; 76 }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}")} 77 )''; 78 79 nativeCheckInputs = [ 80 django 81 flask 82 gevent 83 psutil 84 pytest-timeout 85 pytest-xdist 86 pytestCheckHook 87 requests 88 ]; 89 90 preCheck = '' 91 export DEBUGPY_PROCESS_SPAWN_TIMEOUT=0 92 export DEBUGPY_PROCESS_EXIT_TIMEOUT=0 93 '' + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) '' 94 # https://github.com/python/cpython/issues/74570#issuecomment-1093748531 95 export no_proxy='*'; 96 ''; 97 98 postCheck = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) '' 99 unset no_proxy 100 ''; 101 102 # Override default arguments in pytest.ini 103 pytestFlagsArray = [ 104 "--timeout=0" 105 ]; 106 107 # Fixes hanging tests on Darwin 108 __darwinAllowLocalNetworking = true; 109 110 disabledTests = [ 111 # testsuite gets stuck at this one 112 "test_attach_pid_client" 113 ]; 114 115 pythonImportsCheck = [ 116 "debugpy" 117 ]; 118 119 meta = with lib; { 120 description = "An implementation of the Debug Adapter Protocol for Python"; 121 homepage = "https://github.com/microsoft/debugpy"; 122 changelog = "https://github.com/microsoft/debugpy/releases/tag/v${version}"; 123 license = licenses.mit; 124 maintainers = with maintainers; [ kira-bruneau ]; 125 platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "i686-darwin" "aarch64-darwin" ]; 126 }; 127}