1{ lib
2, fetchPypi
3, buildPythonPackage
4, pytestCheckHook
5, pycparser
6, psutil
7, dotnet-sdk
8, buildDotnetModule
9, clr-loader
10, setuptools
11}:
12
13let
14 pname = "pythonnet";
15 version = "3.0.3";
16 src = fetchPypi {
17 pname = "pythonnet";
18 inherit version;
19 hash = "sha256-jUsulxWKAjh1+GR0WKWPOIF/T+Oa9gq91rDYrfHXfnU=";
20 };
21
22 # This buildDotnetModule is used only to get nuget sources, the actual
23 # build is done in `buildPythonPackage` below.
24 dotnet-build = buildDotnetModule {
25 inherit pname version src;
26 nugetDeps = ./deps.nix;
27 };
28in
29buildPythonPackage {
30 inherit pname version src;
31
32 format = "pyproject";
33
34 postPatch = ''
35 substituteInPlace pyproject.toml \
36 --replace 'dynamic = ["version"]' 'version = "${version}"'
37 '';
38
39 nativeBuildInputs = [
40 setuptools
41 dotnet-sdk
42 ];
43
44 propagatedBuildInputs = [
45 pycparser
46 clr-loader
47 ];
48
49 pytestFlagsArray = [
50 # Run tests using .NET Core, Mono is unsupported for now due to find_library problem in clr-loader
51 "--runtime coreclr"
52 ];
53
54 nativeCheckInputs = [
55 pytestCheckHook
56 psutil # needed for memory leak tests
57 ];
58
59 # Perform dotnet restore based on the nuget-source
60 preConfigure = ''
61 dotnet restore \
62 -p:ContinuousIntegrationBuild=true \
63 -p:Deterministic=true \
64 --source ${dotnet-build.nuget-source}
65 '';
66
67 # Rerun this when updating to refresh Nuget dependencies
68 passthru.fetch-deps = dotnet-build.fetch-deps;
69
70 meta = with lib; {
71 description = ".NET integration for Python";
72 homepage = "https://pythonnet.github.io";
73 changelog = "https://github.com/pythonnet/pythonnet/releases/tag/v${version}";
74 license = licenses.mit;
75 # <https://github.com/pythonnet/pythonnet/issues/898>
76 badPlatforms = [ "aarch64-linux" ];
77 maintainers = with maintainers; [ jraygauthier mdarocha ];
78 };
79}