Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at r-updates 159 lines 4.3 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 pythonOlder, 6 pythonAtLeast, 7 fetchFromGitHub, 8 replaceVars, 9 gdb, 10 lldb, 11 pytestCheckHook, 12 pytest-xdist, 13 pytest-timeout, 14 pytest-retry, 15 importlib-metadata, 16 psutil, 17 untangle, 18 django, 19 flask, 20 gevent, 21 numpy, 22 requests, 23 typing-extensions, 24}: 25 26buildPythonPackage rec { 27 pname = "debugpy"; 28 version = "1.8.16"; 29 format = "setuptools"; 30 31 disabled = pythonOlder "3.8"; 32 33 src = fetchFromGitHub { 34 owner = "microsoft"; 35 repo = "debugpy"; 36 tag = "v${version}"; 37 hash = "sha256-11P2L3/ePoKrqO2G65XJeDEB6lsC8h7oRyXzGRz18tg="; 38 }; 39 40 patches = [ 41 # Use nixpkgs version instead of versioneer 42 (replaceVars ./hardcode-version.patch { 43 inherit version; 44 }) 45 46 # Fix importing debugpy in: 47 # - test_nodebug[module-launch(externalTerminal)] 48 # - test_nodebug[module-launch(integratedTerminal)] 49 # 50 # NOTE: The import failures seen in these tests without the patch 51 # will be seen if a user "installs" debugpy by adding it to PYTHONPATH. 52 # To avoid this issue, debugpy should be installed using python.withPackages: 53 # python.withPackages (ps: with ps; [ debugpy ]) 54 ./fix-test-pythonpath.patch 55 56 # Attach pid tests are disabled by default on windows & macos, 57 # but are also flaky on linux: 58 # - https://github.com/NixOS/nixpkgs/issues/262000 59 # - https://github.com/NixOS/nixpkgs/issues/251045 60 ./skip-attach-pid-tests.patch 61 ] 62 ++ lib.optionals stdenv.hostPlatform.isLinux [ 63 # Hard code GDB path (used to attach to process) 64 (replaceVars ./hardcode-gdb.patch { 65 inherit gdb; 66 }) 67 ] 68 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 69 # Hard code LLDB path (used to attach to process) 70 (replaceVars ./hardcode-lldb.patch { 71 inherit lldb; 72 }) 73 ]; 74 75 # Compile attach library for host platform 76 # Derived from linux_and_mac/compile_linux.sh & linux_and_mac/compile_mac.sh 77 preBuild = '' 78 ( 79 set -x 80 cd src/debugpy/_vendored/pydevd/pydevd_attach_to_process 81 $CXX linux_and_mac/attach.cpp -Ilinux_and_mac -std=c++11 -fPIC -nostartfiles ${ 82 { 83 "x86_64-linux" = "-shared -o attach_linux_amd64.so"; 84 "i686-linux" = "-shared -o attach_linux_x86.so"; 85 "aarch64-linux" = "-shared -o attach_linux_arm64.so"; 86 "riscv64-linux" = "-shared -o attach_linux_riscv64.so"; 87 "x86_64-darwin" = "-D_REENTRANT -dynamiclib -lc -o attach.dylib"; 88 "aarch64-darwin" = "-D_REENTRANT -dynamiclib -lc -o attach.dylib"; 89 } 90 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}") 91 } 92 )''; 93 94 # Disable tests for unmaintained versions of python 95 doCheck = pythonAtLeast "3.11"; 96 97 nativeCheckInputs = [ 98 ## Used to run the tests: 99 pytestCheckHook 100 pytest-xdist 101 pytest-timeout 102 pytest-retry 103 104 ## Used by test helpers: 105 importlib-metadata 106 psutil 107 untangle 108 109 ## Used in Python code that is run/debugged by the tests: 110 django 111 flask 112 gevent 113 numpy 114 requests 115 typing-extensions 116 ]; 117 118 preCheck = '' 119 export DEBUGPY_PROCESS_SPAWN_TIMEOUT=0 120 export DEBUGPY_PROCESS_EXIT_TIMEOUT=0 121 '' 122 + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) '' 123 # https://github.com/python/cpython/issues/74570#issuecomment-1093748531 124 export no_proxy='*'; 125 ''; 126 127 postCheck = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) '' 128 unset no_proxy 129 ''; 130 131 # Override default arguments in pytest.ini 132 pytestFlags = [ "--timeout=0" ]; 133 134 disabledTests = [ 135 # hanging test (flaky) 136 "test_systemexit" 137 ]; 138 139 # Fixes hanging tests on Darwin 140 __darwinAllowLocalNetworking = true; 141 142 pythonImportsCheck = [ "debugpy" ]; 143 144 meta = with lib; { 145 description = "Implementation of the Debug Adapter Protocol for Python"; 146 homepage = "https://github.com/microsoft/debugpy"; 147 changelog = "https://github.com/microsoft/debugpy/releases/tag/${src.tag}"; 148 license = licenses.mit; 149 maintainers = with maintainers; [ kira-bruneau ]; 150 platforms = [ 151 "x86_64-linux" 152 "i686-linux" 153 "aarch64-linux" 154 "x86_64-darwin" 155 "aarch64-darwin" 156 "riscv64-linux" 157 ]; 158 }; 159}