1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 makefun,
12 multipledispatch,
13 numpy,
14 opt-einsum,
15 typing-extensions,
16
17 # checks
18 pyro-ppl,
19 torch,
20 pandas,
21 pillow,
22 pyro-api,
23 pytestCheckHook,
24 pytest-xdist,
25 requests,
26 scipy,
27 torchvision,
28
29 stdenv,
30}:
31
32buildPythonPackage rec {
33 pname = "funsor";
34 version = "0.4.6";
35 pyproject = true;
36
37 disabled = pythonOlder "3.7";
38
39 src = fetchFromGitHub {
40 owner = "pyro-ppl";
41 repo = "funsor";
42 tag = version;
43 hash = "sha256-Prj1saT0yoPAP8rDE0ipBEpR3QMk4PS12VSJlxc22p8=";
44 };
45
46 build-system = [ setuptools ];
47
48 dependencies = [
49 makefun
50 multipledispatch
51 numpy
52 opt-einsum
53 typing-extensions
54 ];
55
56 nativeCheckInputs = [
57 # Backend
58 pyro-ppl
59 torch
60
61 pandas
62 pillow
63 pyro-api
64 pytestCheckHook
65 pytest-xdist
66 requests
67 scipy
68 torchvision
69 ];
70
71 preCheck = ''
72 export FUNSOR_BACKEND=torch
73 '';
74
75 pythonImportsCheck = [ "funsor" ];
76
77 disabledTests = [
78 # `test_torch_save` got broken by the update of torch (2.3.1 -> 2.4.0):
79 # FutureWarning: You are using `torch.load` with `weights_only=False`...
80 # TODO: Try to re-enable this test at next release
81 "test_torch_save"
82 ]
83 ++ lib.optionals stdenv.hostPlatform.isDarwin [
84 # Failures related to JIT
85 # RuntimeError: required keyword attribute 'Subgraph' has the wrong type
86 "test_local_param_ok"
87 "test_plate_ok"
88 ];
89
90 meta = {
91 description = "Functional tensors for probabilistic programming";
92 homepage = "https://funsor.pyro.ai";
93 changelog = "https://github.com/pyro-ppl/funsor/releases/tag/${version}";
94 license = lib.licenses.asl20;
95 maintainers = with lib.maintainers; [ GaetanLepage ];
96 };
97}