1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchNpmDeps,
6 pythonOlder,
7 nodejs,
8 npmHooks,
9 hatchling,
10 hatch-vcs,
11 anywidget,
12 pytestCheckHook,
13}:
14
15buildPythonPackage rec {
16 pname = "ipyniivue";
17 version = "2.1.0";
18 pyproject = true;
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "niivue";
24 repo = "ipyniivue";
25 rev = "v${version}";
26 hash = "sha256-rgScBBJ0Jqr5REZ+YFJcKwWcV33RzJ/sn6RqTL/limo=";
27 };
28
29 npmDeps = fetchNpmDeps {
30 name = "${pname}-${version}-npm-deps";
31 inherit src;
32 hash = "sha256-3IR2d4/i/e1dRlvKN21XnadUfx2lP5SuToQJ9tMhzp4=";
33 };
34
35 # We do not need the build hooks, because we do not need to
36 # build any JS components; these are present already in the PyPI artifact.
37 env.HATCH_BUILD_NO_HOOKS = true;
38
39 nativeBuildInputs = [
40 nodejs
41 npmHooks.npmConfigHook
42 ];
43
44 preBuild = ''
45 npm run build
46 '';
47
48 build-system = [
49 hatchling
50 hatch-vcs
51 ];
52
53 dependencies = [ anywidget ];
54
55 nativeCheckInputs = [ pytestCheckHook ];
56 pythonImportsCheck = [ "ipyniivue" ];
57
58 meta = with lib; {
59 description = "Show a nifti image in a webgl 2.0 canvas within a jupyter notebook cell";
60 homepage = "https://github.com/niivue/ipyniivue";
61 changelog = "https://github.com/niivue/ipyniivue/releases/tag/${version}";
62 license = licenses.bsd3;
63 maintainers = with maintainers; [ bcdarwin ];
64 };
65}