diff --git a/pkgs/development/python-modules/highdicom/default.nix b/pkgs/development/python-modules/highdicom/default.nix new file mode 100644 index 000000000000..b4420e6de9d4 --- /dev/null +++ b/pkgs/development/python-modules/highdicom/default.nix @@ -0,0 +1,79 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pythonOlder +, pytestCheckHook +, numpy +, pillow +, pillow-jpls +, pydicom +, pylibjpeg +, pylibjpeg-libjpeg +}: + +let + test_data = fetchFromGitHub { + owner = "pydicom"; + repo = "pydicom-data"; + rev = "cbb9b2148bccf0f550e3758c07aca3d0e328e768"; + hash = "sha256-nF/j7pfcEpWHjjsqqTtIkW8hCEbuQ3J4IxpRk0qc1CQ="; + }; +in +buildPythonPackage rec { + pname = "highdicom"; + version = "0.22.0"; + pyproject = true; + + disabled = pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "MGHComputationalPathology"; + repo = "highdicom"; + rev = "refs/tags/v${version}"; + hash = "sha256-KHSJWEnm8u0xHkeeLF/U7MY4FfiWb6Q0GQQy2w1mnKw="; + }; + + propagatedBuildInputs = [ + numpy + pillow + pillow-jpls + pydicom + ]; + + passthru.optional-dependencies = { + libjpeg = [ + pylibjpeg + pylibjpeg-libjpeg + #pylibjpeg-openjpeg # not in nixpkgs yet + ]; + }; + + nativeCheckInputs = [ + pytestCheckHook + ] ++ passthru.optional-dependencies.libjpeg; + preCheck = '' + export HOME=$TMP/test-home + mkdir -p $HOME/.pydicom/ + ln -s ${test_data}/data_store/data $HOME/.pydicom/data + ''; + + pythonImportsCheck = [ + "highdicom" + "highdicom.legacy" + "highdicom.ann" + "highdicom.ko" + "highdicom.pm" + "highdicom.pr" + "highdicom.seg" + "highdicom.sr" + "highdicom.sc" + ]; + + meta = with lib; { + description = "High-level DICOM abstractions for Python"; + homepage = "https://highdicom.readthedocs.io"; + changelog = "https://github.com/ImagingDataCommons/highdicom/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ bcdarwin ]; + }; +} diff --git a/pkgs/development/python-modules/pillow-jpls/default.nix b/pkgs/development/python-modules/pillow-jpls/default.nix new file mode 100644 index 000000000000..e6d65ac381f0 --- /dev/null +++ b/pkgs/development/python-modules/pillow-jpls/default.nix @@ -0,0 +1,82 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, fetchPypi +, fetchpatch +, pythonOlder +, pytestCheckHook +, cmake +, ninja +, scikit-build-core +, charls +, eigen +, fmt +, numpy +, pillow +, pybind11 +, setuptools +, pathspec +, pyproject-metadata +, setuptools_scm +}: + +buildPythonPackage rec { + pname = "pillow-jpls"; + version = "1.3.2"; + pyproject = true; + + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "planetmarshall"; + repo = "pillow-jpls"; + rev = "refs/tags/v${version}"; + hash = "sha256-Rc4/S8BrYoLdn7eHDBaoUt1Qy+h0TMAN5ixCAuRmfPU="; + }; + + postPatch = '' + substituteInPlace pyproject.toml --replace '"conan~=2.0.16",' "" + ''; + + nativeBuildInputs = [ + cmake + ninja + pybind11 + scikit-build-core + setuptools + setuptools_scm + ]; + buildInputs = [ + charls + eigen + fmt + ]; + propagatedBuildInputs = [ + numpy + pillow + pathspec + pyproject-metadata + ]; + + pypaBuildFlags = [ "-C" "cmake.args='--preset=sysdeps'" ]; + dontUseCmakeConfigure = true; + + env.SETUPTOOLS_SCM_PRETEND_VERSION = version; + + checkInputs = [ + pytestCheckHook + ]; + # prevent importing from build during test collection: + preCheck = ''rm -rf pillow_jpls''; + + pythonImportsCheck = [ + "pillow_jpls" + ]; + + meta = with lib; { + description = "A JPEG-LS plugin for the Python Pillow library"; + homepage = "https://github.com/planetmarshall/pillow-jpls"; + license = licenses.bsd3; + maintainers = with maintainers; [ bcdarwin ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 44142dcf55a6..d4ea537d2229 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5169,6 +5169,8 @@ self: super: with self; { hickle = callPackage ../development/python-modules/hickle { }; + highdicom = callPackage ../development/python-modules/highdicom { }; + hid = callPackage ../development/python-modules/hid { inherit (pkgs) hidapi; }; @@ -9372,6 +9374,8 @@ self: super: with self; { pillow-heif = callPackage ../development/python-modules/pillow-heif { }; + pillow-jpls = callPackage ../development/python-modules/pillow-jpls { }; + pillow-simd = callPackage ../development/python-modules/pillow-simd { inherit (pkgs) freetype libjpeg zlib libtiff libwebp tcl lcms2 tk; inherit (pkgs.xorg) libX11;