Merge branch 'openslide' into 'master'
openslide: Initial packaging (includes python interface) * Add upstream commit 4ea9211 for Pillow issue 2259 See merge request !3
This commit is contained in:
33
openslide/default.nix
Normal file
33
openslide/default.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
with import <nixpkgs> { };
|
||||
|
||||
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
|
||||
];
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
39
openslide/python.nix
Normal file
39
openslide/python.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
with import <nixpkgs> {};
|
||||
|
||||
let
|
||||
|
||||
openslide = import ./default.nix;
|
||||
|
||||
in
|
||||
|
||||
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 = {
|
||||
homepage = "http://openslide.org";
|
||||
description = "Python bindings for OpenSlide.";
|
||||
license = licenses.lgpl2;
|
||||
};
|
||||
}
|
||||
82
openslide/zero-size-test-skip.patch
Normal file
82
openslide/zero-size-test-skip.patch
Normal 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))
|
||||
Reference in New Issue
Block a user