1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5
6 jupyterlab,
7 setuptools,
8
9 ipywidgets,
10 ipydatawidgets,
11 numpy,
12 traitlets,
13}:
14
15buildPythonPackage rec {
16 pname = "pythreejs";
17 version = "2.4.2";
18 pyproject = true;
19
20 # github sources need to invoke npm, but no package-lock.json present:
21 # https://github.com/jupyter-widgets/pythreejs/issues/419
22 src = fetchPypi {
23 inherit pname version;
24 hash = "sha256-pWi/3Ew3l8TCM5FYko7cfc9vpKJnsI487FEh4geLW9Y=";
25 };
26
27 build-system = [
28 jupyterlab
29 setuptools
30 ];
31
32 # It seems pythonRelaxDeps doesn't work for these
33 postPatch = ''
34 substituteInPlace pyproject.toml \
35 --replace-fail "jupyterlab~=" "jupyterlab>="
36
37 # https://github.com/jupyter-widgets/pythreejs/pull/420
38 substituteInPlace setupbase.py \
39 --replace-fail "import pipes" "" \
40 --replace-fail "pipes.quote" "shlex.quote"
41 '';
42
43 # Don't run npm install, all files are already where they should be present.
44 # If we would run npm install, npm would detect package-lock.json is an old format,
45 # and try to fetch more metadata from the registry, which cannot work in the sandbox.
46 setupPyBuildFlags = [ "--skip-npm" ];
47
48 dependencies = [
49 ipywidgets
50 ipydatawidgets
51 numpy
52 traitlets
53 ];
54
55 # There are no tests
56 doCheck = false;
57
58 pythonImportsCheck = [ "pythreejs" ];
59
60 meta = {
61 description = "Interactive 3D graphics for the Jupyter Notebook and JupyterLab, using Three.js and Jupyter Widgets";
62 homepage = "https://github.com/jupyter-widgets/pythreejs";
63 changelog = "https://github.com/jupyter-widgets/pythreejs/releases/tag/${version}";
64 license = lib.licenses.bsd3;
65 maintainers = with lib.maintainers; [ flokli ];
66 };
67}