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