From 648d25733e25991074c6d50eed437191eafbaeb4 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Wed, 8 May 2024 03:33:56 +0200 Subject: [PATCH] python312Packages.glymur: 0.12.5 -> 0.13.2, unbreak, refactor --- .../python-modules/glymur/default.nix | 47 ++++++++++++------- .../python-modules/glymur/set-lib-paths.patch | 16 +++++++ 2 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 pkgs/development/python-modules/glymur/set-lib-paths.patch diff --git a/pkgs/development/python-modules/glymur/default.nix b/pkgs/development/python-modules/glymur/default.nix index 4ff23443e40d..0f8ad79c72b2 100644 --- a/pkgs/development/python-modules/glymur/default.nix +++ b/pkgs/development/python-modules/glymur/default.nix @@ -1,10 +1,13 @@ { lib , stdenv , buildPythonPackage +, substituteAll +, glibc +, libtiff +, openjpeg , fetchFromGitHub , lxml , numpy -, openjpeg , pytestCheckHook , pythonOlder , scikit-image @@ -13,54 +16,66 @@ buildPythonPackage rec { pname = "glymur"; - version = "0.12.5"; - format = "pyproject"; + version = "0.13.2"; + pyproject = true; disabled = pythonOlder "3.6"; src = fetchFromGitHub { owner = "quintusdias"; - repo = pname; + repo = "glymur"; rev = "refs/tags/v${version}"; - hash = "sha256-9NMSAt5yFRnlCUDP37/ozhDsS8FTdRkfjUz8kQwWzVc="; + hash = "sha256-GUqe9mdMm2O/cbZw8Reohh4X1kO+xOMWHb83PjNvdu8="; }; - nativeBuildInputs = [ + patches = [ + (substituteAll { + src = ./set-lib-paths.patch; + openjp2_lib = "${lib.getLib openjpeg}/lib/libopenjp2${stdenv.hostPlatform.extensions.sharedLibrary}"; + tiff_lib = "${lib.getLib libtiff}/lib/libtiff${stdenv.hostPlatform.extensions.sharedLibrary}"; + }) + ]; + + postPatch = lib.optionalString (!stdenv.isDarwin) '' + substituteInPlace glymur/lib/tiff.py \ + --replace-fail "glymur_config('c')" "ctypes.CDLL('${lib.getLib glibc}/lib/libc.so.6')" + ''; + + __propagatedImpureHostDeps = lib.optional stdenv.isDarwin "/usr/lib/libc.dylib"; + + build-system = [ setuptools ]; - propagatedBuildInputs = [ + dependencies = [ + lxml numpy ]; nativeCheckInputs = [ - lxml pytestCheckHook scikit-image ]; - postConfigure = '' - substituteInPlace glymur/config.py \ - --replace "path = read_config_file(libname)" "path = '${openjpeg}/lib/lib' + libname + ${if stdenv.isDarwin then "'.dylib'" else "'.so'"}" + preCheck = '' + export PATH="$out/bin:$PATH" ''; disabledTestPaths = [ # this test involves glymur's different ways of finding the openjpeg path on # fsh systems by reading an .rc file and such, and is obviated by the patch - # in postConfigure "tests/test_config.py" - "tests/test_tiff2jp2.py" ]; pythonImportsCheck = [ "glymur" ]; - meta = with lib; { + meta = { description = "Tools for accessing JPEG2000 files"; homepage = "https://github.com/quintusdias/glymur"; changelog = "https://github.com/quintusdias/glymur/blob/v${version}/CHANGES.txt"; - license = licenses.mit; - maintainers = with maintainers; [ ]; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ tomasajt ]; }; } diff --git a/pkgs/development/python-modules/glymur/set-lib-paths.patch b/pkgs/development/python-modules/glymur/set-lib-paths.patch new file mode 100644 index 000000000000..4ae7b58b1cdc --- /dev/null +++ b/pkgs/development/python-modules/glymur/set-lib-paths.patch @@ -0,0 +1,16 @@ +diff --git a/glymur/config.py b/glymur/config.py +index 962e299..dab44ba 100644 +--- a/glymur/config.py ++++ b/glymur/config.py +@@ -53,6 +53,11 @@ def _determine_full_path(libname): + if path is not None: + return path + ++ if libname == "openjp2": ++ return "@openjp2_lib@" ++ if libname == "tiff": ++ return "@tiff_lib@" ++ + # No joy on config file. Cygwin? Cygwin is a bit of an odd case. + if platform.system().startswith('CYGWIN'): + g = pathlib.Path('/usr/bin').glob('cygopenjp2*.dll')