1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 pytestCheckHook,
6 dotnetCorePackages,
7 setuptools,
8 setuptools-scm,
9 wheel,
10 buildDotnetModule,
11 cffi,
12}:
13
14let
15 pname = "clr-loader";
16 version = "0.2.7.post0";
17 src = fetchPypi {
18 pname = "clr_loader";
19 inherit version;
20 hash = "sha256-t6iz+PuxvLu2OC2IfiHRdC1PELXqIJ5K2VVo/pfhx8Y=";
21 };
22 patches = [ ./dotnet-8-upgrade.patch ];
23 # This stops msbuild from picking up $version from the environment
24 postPatch = ''
25 echo '<Project><PropertyGroup><Version/></PropertyGroup></Project>' > \
26 Directory.Build.props
27 '';
28
29 # This buildDotnetModule is used only to get nuget sources, the actual
30 # build is done in `buildPythonPackage` below.
31 dotnet-build = buildDotnetModule {
32 inherit
33 pname
34 version
35 src
36 patches
37 postPatch
38 ;
39 projectFile = [
40 "netfx_loader/ClrLoader.csproj"
41 "example/example.csproj"
42 ];
43 nugetDeps = ./deps.json;
44 dotnet-sdk = dotnetCorePackages.sdk_8_0;
45 };
46in
47buildPythonPackage {
48 inherit
49 pname
50 version
51 src
52 patches
53 postPatch
54 ;
55
56 format = "pyproject";
57
58 buildInputs = dotnetCorePackages.sdk_8_0.packages ++ dotnet-build.nugetDeps;
59
60 nativeBuildInputs = [
61 setuptools
62 setuptools-scm
63 wheel
64 dotnetCorePackages.sdk_8_0
65 ];
66
67 propagatedBuildInputs = [ cffi ];
68
69 nativeCheckInputs = [ pytestCheckHook ];
70
71 disabledTests = [
72 # TODO: mono does not work due to https://github.com/NixOS/nixpkgs/issues/7307
73 "test_mono"
74 "test_mono_debug"
75 "test_mono_signal_chaining"
76 "test_mono_set_dir"
77 ];
78
79 # Perform dotnet restore based on the nuget-source
80 preConfigure = ''
81 dotnet restore "netfx_loader/ClrLoader.csproj" \
82 -p:ContinuousIntegrationBuild=true \
83 -p:Deterministic=true
84
85 dotnet restore "example/example.csproj" \
86 -p:ContinuousIntegrationBuild=true \
87 -p:Deterministic=true
88 '';
89
90 passthru.fetch-deps = dotnet-build.fetch-deps;
91
92 meta = with lib; {
93 description = "Generic pure Python loader for .NET runtimes";
94 homepage = "https://pythonnet.github.io/clr-loader/";
95 license = licenses.mit;
96 maintainers = with maintainers; [ mdarocha ];
97 };
98}