1{ lib
2, fetchPypi
3, fetchNuGet
4, buildPythonPackage
5, python
6, pytest
7, pycparser
8, psutil
9, pkgconfig
10, dotnetbuildhelpers
11, clang
12, glib
13, mono
14}:
15
16let
17
18 UnmanagedExports127 = fetchNuGet {
19 baseName = "UnmanagedExports";
20 version = "1.2.7";
21 sha256 = "0bfrhpmq556p0swd9ssapw4f2aafmgp930jgf00sy89hzg2bfijf";
22 outputFiles = [ "*" ];
23 };
24
25 NUnit371 = fetchNuGet {
26 baseName = "NUnit";
27 version = "3.7.1";
28 sha256 = "1yc6dwaam4w2ss1193v735nnl79id78yswmpvmjr1w4bgcbdza4l";
29 outputFiles = [ "*" ];
30 };
31
32in
33
34buildPythonPackage rec {
35 pname = "pythonnet";
36 version = "2.4.0";
37
38 src = fetchPypi {
39 inherit pname version;
40 sha256 = "1ach9jic7a9rd3vmc4bphkr9fq01a0qk81f8a7gr9npwzmkqx8x3";
41 };
42
43 postPatch = ''
44 substituteInPlace setup.py --replace 'self._install_packages()' '#self._install_packages()'
45 '';
46
47 preConfigure = ''
48 [ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh
49 [ -z "''${dontPlacatePaket-}" ] && placate-paket.sh
50 '';
51
52 nativeBuildInputs = [
53 pytest
54 pycparser
55
56 pkgconfig
57 dotnetbuildhelpers
58 clang
59
60 mono
61
62 NUnit371
63 UnmanagedExports127
64 ];
65
66 buildInputs = [
67 glib
68 mono
69 psutil # needed for memory leak tests
70 ];
71
72 preBuild = ''
73 rm -rf packages
74 mkdir packages
75
76 ln -s ${NUnit371}/lib/dotnet/NUnit/ packages/NUnit.3.7.1
77 ln -s ${UnmanagedExports127}/lib/dotnet/NUnit/ packages/UnmanagedExports.1.2.7
78
79 # Setting TERM=xterm fixes an issue with terminfo in mono: System.Exception: Magic number is wrong: 542
80 export TERM=xterm
81 '';
82
83 checkPhase = ''
84 ${python.interpreter} -m pytest
85 '';
86
87 meta = with lib; {
88 description = ".Net and Mono integration for Python";
89 homepage = "https://pythonnet.github.io";
90 license = licenses.mit;
91 maintainers = with maintainers; [ jraygauthier ];
92 broken = true;
93 };
94}