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