summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ipyniivue/default.nix
blob: 6c36a1a7fb83ca6917bb95d9649a1d82aee99f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchNpmDeps,
  nodejs,
  npmHooks,
  hatchling,
  hatch-vcs,
  anywidget,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "ipyniivue";
  version = "2.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "niivue";
    repo = "ipyniivue";
    rev = "v${version}";
    hash = "sha256-rgScBBJ0Jqr5REZ+YFJcKwWcV33RzJ/sn6RqTL/limo=";
  };

  npmDeps = fetchNpmDeps {
    name = "${pname}-${version}-npm-deps";
    inherit src;
    hash = "sha256-3IR2d4/i/e1dRlvKN21XnadUfx2lP5SuToQJ9tMhzp4=";
  };

  # We do not need the build hooks, because we do not need to
  # build any JS components; these are present already in the PyPI artifact.
  env.HATCH_BUILD_NO_HOOKS = true;

  nativeBuildInputs = [
    nodejs
    npmHooks.npmConfigHook
  ];

  preBuild = ''
    npm run build
  '';

  build-system = [
    hatchling
    hatch-vcs
  ];

  dependencies = [ anywidget ];

  nativeCheckInputs = [ pytestCheckHook ];
  pythonImportsCheck = [ "ipyniivue" ];

  meta = {
    description = "Show a nifti image in a webgl 2.0 canvas within a jupyter notebook cell";
    homepage = "https://github.com/niivue/ipyniivue";
    changelog = "https://github.com/niivue/ipyniivue/releases/tag/${version}";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ bcdarwin ];
  };
}