Merge pull request #309998 from TomaSajt/glymur

python312Packages.glymur: 0.12.5 -> 0.13.2, unbreak, refactor
This commit is contained in:
Weijia Wang 2024-05-10 08:44:48 +02:00 committed by GitHub
commit 5c31c00140
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 16 deletions

View file

@ -1,10 +1,13 @@
{ lib { lib
, stdenv , stdenv
, buildPythonPackage , buildPythonPackage
, substituteAll
, glibc
, libtiff
, openjpeg
, fetchFromGitHub , fetchFromGitHub
, lxml , lxml
, numpy , numpy
, openjpeg
, pytestCheckHook , pytestCheckHook
, pythonOlder , pythonOlder
, scikit-image , scikit-image
@ -13,54 +16,66 @@
buildPythonPackage rec { buildPythonPackage rec {
pname = "glymur"; pname = "glymur";
version = "0.12.5"; version = "0.13.2";
format = "pyproject"; pyproject = true;
disabled = pythonOlder "3.6"; disabled = pythonOlder "3.6";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "quintusdias"; owner = "quintusdias";
repo = pname; repo = "glymur";
rev = "refs/tags/v${version}"; 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 setuptools
]; ];
propagatedBuildInputs = [ dependencies = [
lxml
numpy numpy
]; ];
nativeCheckInputs = [ nativeCheckInputs = [
lxml
pytestCheckHook pytestCheckHook
scikit-image scikit-image
]; ];
postConfigure = '' preCheck = ''
substituteInPlace glymur/config.py \ export PATH="$out/bin:$PATH"
--replace "path = read_config_file(libname)" "path = '${openjpeg}/lib/lib' + libname + ${if stdenv.isDarwin then "'.dylib'" else "'.so'"}"
''; '';
disabledTestPaths = [ disabledTestPaths = [
# this test involves glymur's different ways of finding the openjpeg path on # 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 # fsh systems by reading an .rc file and such, and is obviated by the patch
# in postConfigure
"tests/test_config.py" "tests/test_config.py"
"tests/test_tiff2jp2.py"
]; ];
pythonImportsCheck = [ pythonImportsCheck = [
"glymur" "glymur"
]; ];
meta = with lib; { meta = {
description = "Tools for accessing JPEG2000 files"; description = "Tools for accessing JPEG2000 files";
homepage = "https://github.com/quintusdias/glymur"; homepage = "https://github.com/quintusdias/glymur";
changelog = "https://github.com/quintusdias/glymur/blob/v${version}/CHANGES.txt"; changelog = "https://github.com/quintusdias/glymur/blob/v${version}/CHANGES.txt";
license = licenses.mit; license = lib.licenses.mit;
maintainers = with maintainers; [ ]; maintainers = with lib.maintainers; [ tomasajt ];
}; };
} }

View file

@ -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')