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