1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pytestCheckHook,
6 writableTmpDirAsHomeHook,
7 pythonOlder,
8 hatch-jupyter-builder,
9 hatchling,
10 importlib-metadata,
11 ipykernel,
12 ipywidgets,
13 psygnal,
14 pydantic,
15 typing-extensions,
16 watchfiles,
17}:
18
19buildPythonPackage rec {
20 pname = "anywidget";
21 version = "0.9.18";
22 pyproject = true;
23
24 disabled = pythonOlder "3.7";
25
26 src = fetchPypi {
27 inherit pname version;
28 hash = "sha256-Jiz0WbUXp9BE1vvIS5U+nIPwJnkLLdPOkPIaf47e0A8=";
29 };
30
31 # We do not need the jupyterlab build dependency, because we do not need to
32 # build any JS components; these are present already in the PyPI artifact.
33 #
34 postPatch = ''
35 substituteInPlace pyproject.toml \
36 --replace '"jupyterlab==3.*"' ""
37 '';
38
39 build-system = [
40 hatch-jupyter-builder
41 hatchling
42 ];
43
44 dependencies = [
45 ipywidgets
46 psygnal
47 typing-extensions
48 ]
49 ++ lib.optional (pythonOlder "3.8") importlib-metadata;
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 ipykernel
54 pydantic
55 watchfiles
56 writableTmpDirAsHomeHook
57 ];
58
59 disabledTests = [
60 # requires package.json
61 "test_version"
62
63 # AssertionError: assert not {140737277121872: <MockComm id='140737277118512'>}
64 "test_descriptor_with_psygnal"
65 "test_descriptor_with_pydantic"
66 "test_descriptor_with_msgspec"
67 "test_descriptor_with_traitlets"
68 "test_infer_file_contents"
69
70 # assert not {<function _connect_psygnal.<locals>._disconnect at 0x7ffff3617e...
71 "test_descriptor_with_psygnal"
72 ];
73
74 pythonImportsCheck = [ "anywidget" ];
75
76 meta = with lib; {
77 description = "Custom jupyter widgets made easy";
78 homepage = "https://github.com/manzt/anywidget";
79 changelog = "https://github.com/manzt/anywidget/releases/tag/anywidget%40${version}";
80 license = licenses.mit;
81 maintainers = with maintainers; [ natsukium ];
82 };
83}