openslide: Convert to new overlay system

This commit is contained in:
Tyson Whitehead
2018-01-18 00:24:42 -05:00
parent ad0a5b2336
commit fa856eb582
5 changed files with 45 additions and 40 deletions

View File

@@ -7,4 +7,8 @@ self: pkgs: with pkgs; {
meraculous = callPackage ./meraculous.nix { };
openfoam = callPackage ./openfoam.nix { };
openslide = callPackage ./openslide { };
openslide-python = callPackage ./openslide/python.nix { };
}

View File

@@ -0,0 +1,39 @@
{ stdenv, autoreconfHook, pkgconfig, fetchFromGitHub
, zlib, openjpeg, libtiff, cairo, libpng, gdk_pixbuf, libxml2, sqlite }:
stdenv.mkDerivation rec {
version = "3.4.1";
name = "openslide-${version}";
src = fetchFromGitHub {
owner = "openslide";
repo = "openslide";
rev = "v${version}";
sha256 = "1g4hhjr4cbx754cwi9wl84k33bkg232w8ajic7aqhzm8x182hszp";
};
buildInputs = [
autoreconfHook
pkgconfig
zlib
openjpeg
libtiff
cairo
libpng
gdk_pixbuf
libxml2
sqlite
];
# Not sure why this Windows test isn't failing under Linux
postPatch = ''
sed -i -e 's|AM_CONDITIONAL(\[WINDOWS_RESOURCES\], \[test x$RC != x\])|AM_CONDITIONAL([WINDOWS_RESOURCES], [false])|' configure.ac
'';
meta = with stdenv.lib; {
homepage = http://openslide.org;
description = "A C library that provides a simple interface to read whole-slide images.";
platforms = platforms.all;
license = licenses.lgpl2;
};
}

34
pkgs/openslide/python.nix Normal file
View File

@@ -0,0 +1,34 @@
{ lib, fetchFromGitHub
, python27Packages, openslide }:
python27Packages.buildPythonPackage rec {
version = "1.1.1";
name = "openslide-python-${version}";
src = fetchFromGitHub {
owner = "openslide";
repo = "openslide-python";
rev = "v${version}";
sha256 = "1is8g8vy8s1xgfw8q76gdx8ygwvj56cl0vxfd3lx0iys15wzs7a4";
};
patches = [ ./zero-size-test-skip.patch ];
postPatch = ''
sed -i 's|LoadLibrary('\'''libopenslide.so.0'\''')|LoadLibrary('\'''${openslide}/lib/libopenslide.so.0'\''')|' openslide/lowlevel.py
'';
buildInputs = [
openslide
];
propagatedBuildInputs = [
python27Packages.pillow
];
meta = with lib; {
homepage = "http://openslide.org";
description = "Python bindings for OpenSlide.";
license = licenses.lgpl2;
};
}

View File

@@ -0,0 +1,82 @@
From 4ea9211e10e9fc58d04bac909d73a2448c4a44ff Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Date: Tue, 24 Jan 2017 23:32:36 -0800
Subject: [PATCH] tests: Avoid spurious failures with Pillow 3.4.0 - 3.4.2
---
tests/__init__.py | 10 ++++++++++
tests/test_imageslide.py | 3 ++-
tests/test_openslide.py | 4 +++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/tests/__init__.py b/tests/__init__.py
index cc2b217..d2158b3 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -19,6 +19,7 @@
from functools import wraps
import os
+from PIL import Image
import unittest
try:
@@ -28,6 +29,15 @@
have_optimizations = False
+# PIL.Image cannot have zero width or height on Pillow 3.4.0 - 3.4.2
+# https://github.com/python-pillow/Pillow/issues/2259
+try:
+ Image.new('RGBA', (1, 0))
+ image_dimensions_cannot_be_zero = False
+except ValueError:
+ image_dimensions_cannot_be_zero = True
+
+
def file_path(name):
return os.path.join(os.path.dirname(__file__), name)
diff --git a/tests/test_imageslide.py b/tests/test_imageslide.py
index bbde9ec..de2a734 100644
--- a/tests/test_imageslide.py
+++ b/tests/test_imageslide.py
@@ -22,7 +22,7 @@
from PIL import Image
import unittest
-from . import file_path
+from . import file_path, image_dimensions_cannot_be_zero, skip_if
# Tests should be written to be compatible with Python 2.6 unittest.
@@ -104,6 +104,7 @@ def test_read_region(self):
self.assertEqual(self.osr.read_region((-10, -10), 0, (400, 400)).size,
(400, 400))
+ @skip_if(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
def test_read_region_size_dimension_zero(self):
self.assertEqual(self.osr.read_region((0, 0), 0, (400, 0)).size,
(400, 0))
diff --git a/tests/test_openslide.py b/tests/test_openslide.py
index 3350c76..b80e2f5 100644
--- a/tests/test_openslide.py
+++ b/tests/test_openslide.py
@@ -25,7 +25,8 @@
import sys
import unittest
-from . import file_path, have_optimizations, skip_if
+from . import (file_path, have_optimizations, image_dimensions_cannot_be_zero,
+ skip_if)
# Tests should be written to be compatible with Python 2.6 unittest.
@@ -110,6 +111,7 @@ def test_read_region(self):
self.assertEqual(self.osr.read_region((-10, -10), 1, (400, 400)).size,
(400, 400))
+ @skip_if(image_dimensions_cannot_be_zero, 'Pillow issue #2259')
def test_read_region_size_dimension_zero(self):
self.assertEqual(self.osr.read_region((0, 0), 1, (400, 0)).size,
(400, 0))