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