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