python3Packages.imageio: fix build, enable most tests
With 624897829b, the new parenthesization logic exposes a coding defect in `imageio` where they do a string test vs. `"not needs_internet"` instead of something parsed.
Instead of fixing that, we can actually enable almost all of the tests in this module with a command-line flag which points to a FOD of https://github.com/imageio/test_images repository.
There are a few more tests that need to be disabled as well; I opened a PR against imageio to fix these.
I also removed the `libgl-path.patch` in favor of a simple `--replace-fail`.
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
buildPythonPackage,
|
||||
fetchFromGitHub,
|
||||
isPyPy,
|
||||
replaceVars,
|
||||
|
||||
# build-system
|
||||
setuptools,
|
||||
@@ -26,9 +25,21 @@
|
||||
|
||||
# tests
|
||||
pytestCheckHook,
|
||||
gitMinimal,
|
||||
fsspec,
|
||||
}:
|
||||
|
||||
let
|
||||
test_images = fetchFromGitHub {
|
||||
owner = "imageio";
|
||||
repo = "test_images";
|
||||
rev = "f676c96b1af7e04bb1eed1e4551e058eb2f14acd";
|
||||
leaveDotGit = true;
|
||||
hash = "sha256-Kh8DowuhcCT5C04bE5yJa2C+efilLxP0AM31XjnHRf4=";
|
||||
};
|
||||
libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
in
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "imageio";
|
||||
version = "2.37.0";
|
||||
@@ -41,11 +52,10 @@ buildPythonPackage rec {
|
||||
hash = "sha256-/nxJxZrTYX7F2grafIWwx9SyfR47ZXyaUwPHMEOdKkI=";
|
||||
};
|
||||
|
||||
patches = lib.optionals (!stdenv.hostPlatform.isDarwin) [
|
||||
(replaceVars ./libgl-path.patch {
|
||||
libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
})
|
||||
];
|
||||
postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
||||
substituteInPlace tests/test_core.py \
|
||||
--replace-fail 'ctypes.util.find_library("GL")' '"${libgl}"'
|
||||
'';
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
@@ -77,14 +87,28 @@ buildPythonPackage rec {
|
||||
|
||||
nativeCheckInputs = [
|
||||
fsspec
|
||||
gitMinimal
|
||||
psutil
|
||||
pytestCheckHook
|
||||
]
|
||||
++ fsspec.optional-dependencies.github
|
||||
++ lib.flatten (builtins.attrValues optional-dependencies);
|
||||
|
||||
pytestFlags = [ "--test-images=file://${test_images}" ];
|
||||
|
||||
# These should have had `needs_internet` mark applied but don't so far.
|
||||
# See https://github.com/imageio/imageio/pull/1142
|
||||
disabledTests = [
|
||||
"test_read_stream"
|
||||
"test_uri_reading"
|
||||
"test_trim_filter"
|
||||
];
|
||||
|
||||
disabledTestMarks = [ "needs_internet" ];
|
||||
|
||||
# These tests require the old and vulnerable freeimage binaries; skip.
|
||||
disabledTestPaths = [ "tests/test_freeimage.py" ];
|
||||
|
||||
preCheck = ''
|
||||
export IMAGEIO_USERDIR=$(mktemp -d)
|
||||
export HOME=$(mktemp -d)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/tests/test_core.py b/tests/test_core.py
|
||||
index 2cdbb3a..032974c 100644
|
||||
--- a/tests/test_core.py
|
||||
+++ b/tests/test_core.py
|
||||
@@ -129,7 +129,7 @@ def test_findlib2():
|
||||
open(os.path.join(fi_dir, "notalib.test.so"), "wb")
|
||||
|
||||
# Loading libs
|
||||
- gllib = ctypes.util.find_library("GL")
|
||||
+ gllib = "@libgl@"
|
||||
core.load_lib([gllib], [])
|
||||
# Fail
|
||||
raises(ValueError, core.load_lib, [], []) # Nothing given
|
||||
Reference in New Issue
Block a user