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 ] ++ lib.optional (pythonOlder "3.8") importlib-metadata;
49
50 nativeCheckInputs = [
51 pytestCheckHook
52 ipykernel
53 pydantic
54 watchfiles
55 writableTmpDirAsHomeHook
56 ];
57
58 disabledTests = [
59 # requires package.json
60 "test_version"
61 ];
62
63 pythonImportsCheck = [ "anywidget" ];
64
65 meta = with lib; {
66 description = "Custom jupyter widgets made easy";
67 homepage = "https://github.com/manzt/anywidget";
68 changelog = "https://github.com/manzt/anywidget/releases/tag/anywidget%40${version}";
69 license = licenses.mit;
70 maintainers = with maintainers; [ natsukium ];
71 };
72}