Unverified Commit 27493716 authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

python3Packages.imageio: fix build, enable most tests (#427800)

parents 597b4538 ffa9e79f
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -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)
+0 −13
Original line number Diff line number Diff line
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