From bcc3996a0d1f03c0c9b0a25ea2069cb72e3b46a2 Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Thu, 24 Dec 2020 08:26:26 +0100 Subject: [PATCH] PKG Add imageio (#919) --- docs/changelog.md | 2 +- packages/imageio/meta.yaml | 14 ++++++++ packages/imageio/patches/setitup.patch | 35 +++++++++++++++++++ packages/imageio/test_imageio.py | 15 ++++++++ packages/scikit-image/meta.yaml | 1 + .../patches/preferred_plugins.patch | 2 +- 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 packages/imageio/meta.yaml create mode 100644 packages/imageio/patches/setitup.patch create mode 100644 packages/imageio/test_imageio.py diff --git a/docs/changelog.md b/docs/changelog.md index 8f8df137f..8695078ba 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -20,7 +20,7 @@ [#846](https://github.com/iodide-project/pyodide/pull/846) - Updated to emscripten 1.38.34 [#480](https://github.com/iodide-project/pyodide/pull/480) -- New packages: freesasa, lxml, python-sat, traits, astropy, pillow +- New packages: freesasa, lxml, python-sat, traits, astropy, pillow, scikit-image, imageio - Updated packages: numpy 1.15.4, pandas 1.0.5, matplotlib 3.3.3 among others. - Updated default `--ldflags` argument to `pyodide_build` scripts to equal what pyodide actually uses. diff --git a/packages/imageio/meta.yaml b/packages/imageio/meta.yaml new file mode 100644 index 000000000..1c9d0bcdc --- /dev/null +++ b/packages/imageio/meta.yaml @@ -0,0 +1,14 @@ +package: + name: imageio + version: 2.9.0 +source: + sha256: 52ddbaeca2dccf53ba2d6dec5676ca7bc3b2403ef8b37f7da78b7654bb3e10f0 + url: https://files.pythonhosted.org/packages/c3/73/f37f428748c4f10a7991ac5bff00f113a34bcc0d0a78957d6e1cdc29a94e/imageio-2.9.0.tar.gz + patches: + - patches/setitup.patch +requirements: + run: + - numpy +test: + imports: + - imageio diff --git a/packages/imageio/patches/setitup.patch b/packages/imageio/patches/setitup.patch new file mode 100644 index 000000000..a086150da --- /dev/null +++ b/packages/imageio/patches/setitup.patch @@ -0,0 +1,35 @@ +diff --git a/imageio/core/findlib.py b/imageio/core/findlib.py +--- a/imageio/core/findlib.py ++++ b/imageio/core/findlib.py +@@ -7,7 +7,6 @@ + + import os + import sys +-import ctypes + + + LOCALDIR = os.path.abspath(os.path.dirname(__file__)) +@@ -95,6 +94,7 @@ def load_lib(exact_lib_names, lib_names, lib_dirs=None): + + Returns ``(ctypes_library, library_path)`` + """ ++ import ctypes + + # Checks + assert isinstance(exact_lib_names, list) + +diff --git a/imageio/plugins/__init__.py b/imageio/plugins/__init__.py +index 7e26683..971f83e 100644 +--- a/imageio/plugins/__init__.py ++++ b/imageio/plugins/__init__.py +@@ -84,8 +84,8 @@ from . import tifffile + from . import pillow + from . import grab + +-from . import freeimage +-from . import freeimagemulti ++# from . import freeimage ++# from . import freeimagemulti + + from . import ffmpeg + diff --git a/packages/imageio/test_imageio.py b/packages/imageio/test_imageio.py new file mode 100644 index 000000000..97e331407 --- /dev/null +++ b/packages/imageio/test_imageio.py @@ -0,0 +1,15 @@ +def test_imageio(selenium): + selenium.load_package(["numpy", "imageio"]) + selenium.run( + r""" +import numpy as np +import imageio + +filename = "/tmp/foo.tif" +image_in = np.random.randint(0, 65535, size=(100, 36), dtype=np.uint16) +imageio.imwrite(filename, image_in) +image_out = imageio.imread(filename) +assert image_out.shape == (100, 36) +np.testing.assert_equal(image_in, image_out) + """ + ) diff --git a/packages/scikit-image/meta.yaml b/packages/scikit-image/meta.yaml index 2d3837584..8f321d416 100644 --- a/packages/scikit-image/meta.yaml +++ b/packages/scikit-image/meta.yaml @@ -15,6 +15,7 @@ requirements: - matplotlib - networkx - pillow + - imageio - pywavelets test: imports: diff --git a/packages/scikit-image/patches/preferred_plugins.patch b/packages/scikit-image/patches/preferred_plugins.patch index f5759bc23..80b21bc42 100644 --- a/packages/scikit-image/patches/preferred_plugins.patch +++ b/packages/scikit-image/patches/preferred_plugins.patch @@ -5,7 +5,7 @@ preferred_plugins = { # Default plugins for all types (overridden by specific types below). - 'all': ['imageio', 'pil', 'matplotlib', 'qt'], -+ 'all': ['pil', 'matplotlib'], ++ 'all': ['imageio', 'pil', 'matplotlib'], 'imshow': ['matplotlib'], 'imshow_collection': ['matplotlib'] }