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