1{ stdenv 2, lib 3, fetchPypi 4, fetchNuGet 5, buildPythonPackage 6, pytestCheckHook 7, pycparser 8, psutil 9, pkg-config 10, dotnetbuildhelpers 11, clang 12, glib 13, mono 14}: 15 16let 17 18 dotnetPkgs = [ 19 (fetchNuGet { 20 pname = "UnmanagedExports"; 21 version = "1.2.7"; 22 sha256 = "0bfrhpmq556p0swd9ssapw4f2aafmgp930jgf00sy89hzg2bfijf"; 23 outputFiles = [ "*" ]; 24 }) 25 (fetchNuGet { 26 pname = "NUnit"; 27 version = "3.12.0"; 28 sha256 = "1880j2xwavi8f28vxan3hyvdnph4nlh5sbmh285s4lc9l0b7bdk2"; 29 outputFiles = [ "*" ]; 30 }) 31 (fetchNuGet { 32 pname = "System.ValueTuple"; 33 version = "4.5.0"; 34 sha256 = "00k8ja51d0f9wrq4vv5z2jhq8hy31kac2rg0rv06prylcybzl8cy"; 35 outputFiles = [ "*" ]; 36 }) 37 ]; 38 39in 40 41buildPythonPackage rec { 42 pname = "pythonnet"; 43 version = "2.5.2"; 44 45 src = fetchPypi { 46 inherit pname version; 47 sha256 = "1qzdc6jd7i9j7p6bcihnr98y005gv1358xqdr1plpbpnl6078a5p"; 48 }; 49 50 postPatch = '' 51 substituteInPlace setup.py --replace 'self._install_packages()' '#self._install_packages()' 52 ''; 53 54 preConfigure = '' 55 [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh 56 [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh 57 ''; 58 59 nativeBuildInputs = [ 60 pycparser 61 62 pkg-config 63 dotnetbuildhelpers 64 clang 65 66 mono 67 68 ] ++ dotnetPkgs; 69 70 buildInputs = [ 71 glib 72 mono 73 ]; 74 75 checkInputs = [ 76 pytestCheckHook 77 psutil # needed for memory leak tests 78 ]; 79 80 preBuild = '' 81 rm -rf packages 82 mkdir packages 83 84 ${builtins.concatStringsSep "\n" ( 85 builtins.map ( 86 x: ''ln -s ${x}/lib/dotnet/${x.pname} ./packages/${x.pname}.${x.version}'' 87 ) dotnetPkgs)} 88 89 # Setting TERM=xterm fixes an issue with terminfo in mono: System.Exception: Magic number is wrong: 542 90 export TERM=xterm 91 ''; 92 93 meta = with lib; { 94 broken = stdenv.isDarwin; 95 description = ".Net and Mono integration for Python"; 96 homepage = "https://pythonnet.github.io"; 97 license = licenses.mit; 98 # <https://github.com/pythonnet/pythonnet/issues/898> 99 badPlatforms = [ "aarch64-linux" ]; 100 maintainers = with maintainers; [ jraygauthier ]; 101 }; 102}