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

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

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

build:
  # these are no longer supported.
  skip: true   # [py<37 or win32]
  number: 0
  ignore_run_exports:
    - libwebp  # [win]
    - jpeg     # [win]
    - jxrlib   # [win]

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  # [not win]
    - m2w64-toolchain  # [win]
  host:
    - m2w64-pkg-config  # [win]
    - python
    - pip
    - numpy-devel {{ numpy }}
    - cython
    - zlib
    - bzip2
    - xz
    - zstd
    - lz4-c                 # [not win]
    - lz4-c >=1.9.3         # [win]
    - libpng
    - libwebp
    - jxrlib
    - jpeg
    - giflib
    - openjpeg
    - blosc
    - lcms2  # [not win32]
    - libaec
    - brotli
    - libzopfli
    - charls          # [not s390x]
    - snappy
    - libtiff
    - lerc            # [not s390x]
    - zfp             # [not s390x]
    - libdeflate
    - brunsli         # [not win and not s390x]
    # While jpeg-turbo is the preferred version upstream, the migration
    # to libjpeg-turbo has been contentious on conda-forge
    # - libjpeg-turbo
  run:
    - python
    # Work around missing `run_exports` in defaults package
    - "{{ pin_compatible('brotli', max_pin='x.x') }}"

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
      # TODO: determine why OpenMP on Windows build workers is unreliable
    - set SKIP_OMP=true                 [win]
    - pytest -vv test_imagecodecs.py
  #   - 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
