{% set name = "imagecodecs" %}
{% set version = "2021.7.30" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
  sha256: 57b4db34718764d77c5ce200f05f387bd68874788ea54fc4c9549215ca68f013

build:
  skip: true  # [py<37]
  number: 0

requirements:
  build:
    - python                                 # [build_platform != target_platform]
    - cross-python_{{ target_platform }}     # [build_platform != target_platform]
    - cython                                 # [build_platform != target_platform]
    - numpy                                  # [build_platform != target_platform]
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - pkg-config
  host:
    - python
    - pip
    - numpy
    - cython
    - zlib
    - bzip2
    - xz
    - zstd
    - lz4-c
    - libpng
    - libwebp
    - jxrlib
    - jpeg
    - giflib
    - openjpeg
    - blosc
    - lcms2
    - libaec
    - brotli
    - libzopfli
    - charls
    - snappy
    - libtiff
    - lerc
    - zfp
    - libdeflate
    - cfitsio
    - brunsli   # [not win]
    # While jpeg-turbo is the preferred version upstream, the migration
    # to libjpeg-turbo has been contentious on conda-forge
    # - libjpeg-turbo
  run:
    - python
    - {{ pin_compatible('numpy') }}

test:
  source_files:
    - tests
  requires:
    - pytest
  # TODO: add these tests when we start to include builds with turbo
  # files:
  #     - 687px-Mona_Lisa,_by_Leonardo_da_Vinci,_from_C2RMF_retouched.jpg
  #     - ensure_jpegturbo_imagecodecs_plays_nicely_with_jpeg9.py
  # requires:
  #   - pillow
  #   - opencv
  imports:
    - imagecodecs
    - imagecodecs._imagecodecs
  commands:
    - cd tests
    # 20210717 hmaarrfk: This test seems to be flaky in the upstream
    # test procedure
    # https://github.com/conda-forge/imagecodecs-feedstock/pull/32#issuecomment-863041029
    - python test_imagecodecs.py -k "not test_image_roundtrips[jpeg2k-uint16-rgb-out-bytearray-None]"
  #   - python ensure_jpegturbo_imagecodecs_plays_nicely_with_jpeg9.py 0
  #   - python ensure_jpegturbo_imagecodecs_plays_nicely_with_jpeg9.py 1

about:
  home: https://www.lfd.uci.edu/~gohlke/
  license: BSD-3-Clause
  license_family: BSD
  license_file:
    - LICENSE
    - 3rdparty/liblzf/LICENSE
    - 3rdparty/bitshuffle/LICENSE
    - 3rdparty/openjpeg/LICENSE
  summary: Image transformation, compression, and decompression codecs
  description: |
    The imagecodecs package provides various block-oriented, in-memory buffer
    transformation, compression, and decompression functions for use in the
    tifffile, czifile, and other Python imaging modules.

    Decode and/or encode functions are currently implemented for Zlib DEFLATE,
    ZStandard, Blosc, LZMA, BZ2, LZ4, LZW, LZF, PNG, WebP, JPEG 8-bit,
    JPEG 12-bit, JPEG SOF=0xC3, JPEG 2000, JPEG XR, PackBits, Packed Integers,
    Delta, XOR Delta, Floating Point Predictor, and Bitorder reversal.

  doc_url: https://www.lfd.uci.edu/~gohlke/
  dev_url: https://github.com/cgohlke/imagecodecs

extra:
  recipe-maintainers:
    - csachs
    - hmaarrfk
    - sdvillal
