1{ lib
2, buildPythonPackage
3, fetchPypi
4, pytestCheckHook
5, pythonOlder
6, hatch-jupyter-builder
7, hatchling
8, importlib-metadata
9, ipywidgets
10, psygnal
11, typing-extensions
12, watchfiles
13}:
14
15buildPythonPackage rec {
16 pname = "anywidget";
17 version = "0.7.1";
18 format = "pyproject";
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchPypi {
23 inherit pname version;
24 hash = "sha256-HEy1EGP47FFyuMjvsb+3mGHTQMNJEiDVa4wqaqjbOz0=";
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 nativeBuildInputs = [
36 hatch-jupyter-builder
37 hatchling
38 ];
39
40 propagatedBuildInputs = [
41 ipywidgets
42 psygnal
43 typing-extensions
44 ] ++ lib.optional (pythonOlder "3.8") importlib-metadata;
45
46 nativeCheckInputs = [
47 pytestCheckHook
48 watchfiles
49 ];
50
51 pythonImportsCheck = [ "anywidget" ];
52
53 meta = with lib; {
54 description = "Custom jupyter widgets made easy";
55 homepage = "https://github.com/manzt/anywidget";
56 changelog = "https://github.com/manzt/anywidget/releases/tag/anywidget%40${version}";
57 license = licenses.mit;
58 maintainers = with maintainers; [ natsukium ];
59 };
60}