diff --git a/pkgs/development/python-modules/pythreejs/default.nix b/pkgs/development/python-modules/pythreejs/default.nix new file mode 100644 index 000000000000..0ad007444f8b --- /dev/null +++ b/pkgs/development/python-modules/pythreejs/default.nix @@ -0,0 +1,67 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + + jupyterlab, + setuptools, + + ipywidgets, + ipydatawidgets, + numpy, + traitlets, +}: + +buildPythonPackage rec { + pname = "pythreejs"; + version = "2.4.2"; + pyproject = true; + + # github sources need to invoke npm, but no package-lock.json present: + # https://github.com/jupyter-widgets/pythreejs/issues/419 + src = fetchPypi { + inherit pname version; + hash = "sha256-pWi/3Ew3l8TCM5FYko7cfc9vpKJnsI487FEh4geLW9Y="; + }; + + build-system = [ + jupyterlab + setuptools + ]; + + # It seems pythonRelaxDeps doesn't work for these + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail "jupyterlab~=" "jupyterlab>=" + + # https://github.com/jupyter-widgets/pythreejs/pull/420 + substituteInPlace setupbase.py \ + --replace-fail "import pipes" "" \ + --replace-fail "pipes.quote" "shlex.quote" + ''; + + # Don't run npm install, all files are already where they should be present. + # If we would run npm install, npm would detect package-lock.json is an old format, + # and try to fetch more metadata from the registry, which cannot work in the sandbox. + setupPyBuildFlags = [ "--skip-npm" ]; + + dependencies = [ + ipywidgets + ipydatawidgets + numpy + traitlets + ]; + + # There are no tests + doCheck = false; + + pythonImportsCheck = [ "pythreejs" ]; + + meta = { + description = "Interactive 3D graphics for the Jupyter Notebook and JupyterLab, using Three.js and Jupyter Widgets"; + homepage = "https://github.com/jupyter-widgets/pythreejs"; + changelog = "https://github.com/jupyter-widgets/pythreejs/releases/tag/${version}"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ flokli ]; + }; +} diff --git a/pkgs/development/python-modules/pythreejs/fix-re.error.patch b/pkgs/development/python-modules/pythreejs/fix-re.error.patch new file mode 100644 index 000000000000..74e75676e7cb --- /dev/null +++ b/pkgs/development/python-modules/pythreejs/fix-re.error.patch @@ -0,0 +1,13 @@ +diff --git a/setupbase.py b/setupbase.py +index 0ce0ac8..7762e23 100644 +--- a/setupbase.py ++++ b/setupbase.py +@@ -659,7 +659,7 @@ def _translate_glob(pat): + translated_parts.append(_translate_glob_part(part)) + os_sep_class = '[%s]' % re.escape(SEPARATORS) + res = _join_translated(translated_parts, os_sep_class) +- return '{res}\\Z(?ms)'.format(res=res) ++ return '(?ms){res}\\Z'.format(res=res) + + + def _join_translated(translated_parts, os_sep_class): diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 62ba4e93a29f..bb05b2d1c6de 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -14363,6 +14363,8 @@ self: super: with self; { pythran = callPackage ../development/python-modules/pythran { inherit (pkgs.llvmPackages) openmp; }; + pythreejs = callPackage ../development/python-modules/pythreejs { }; + pytibber = callPackage ../development/python-modules/pytibber { }; pytikz-allefeld = callPackage ../development/python-modules/pytikz-allefeld { };