{% set name = "zstandard" %}
{% set version = "0.23.0" %}
{% set zstd_version = "1.5.6" %}

package:
  name: {{ name }}
  version: {{ version }}

source:
  url: https://pypi.org/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
  sha256: b2d8c62d08e7255f68f7a740bae85b3c9b8e5466baa9cbf7f57f1cde0ac6bc09
  patches:
    # until https://github.com/indygreg/python-zstandard/pull/255 is merged
    - patches/0001-link-zstd-statically.patch
    - patches/0002-Ensure-c-extension-looks-up-symbols-locally.patch  # [linux]

build:
  number: 2

requirements:
  build:
    - python                                 # [build_platform != target_platform]
    - cross-python_{{ target_platform }}     # [build_platform != target_platform]
    - cffi                                   # [build_platform != target_platform]
    - zstd-static {{ zstd_version }}         # [build_platform != target_platform]
    - {{ compiler('c') }}
    - {{ stdlib("c") }}
  host:
    - python
    - pip
    - setuptools
    - cffi >=1.11
    - zstd-static {{ zstd_version }}
  run:
    - python
    - cffi >=1.11

test:
  requires:
    - pip
    # validate that a newer zstd present in the environment doesn't disturb us
    - zstd 1.5.7
  commands:
    - pip check
    # validate that a newer libzstd.so loaded into memory doesn't conflict us
    - LD_PRELOAD=$CONDA_PREFIX/lib/libzstd.so python run_test.py  # [linux]
  imports:
    - zstandard

about:
  home: https://github.com/indygreg/python-zstandard
  license: BSD-3-Clause
  license_file: LICENSE
  summary: Zstandard bindings for Python
  description: |
    This project provides Python bindings for interfacing with the
    Zstandard compression library. A C extension and CFFI interface are
    provided.
  doc_url: https://github.com/indygreg/python-zstandard/blob/master/README.rst#python-zstandard
  dev_url: https://github.com/indygreg/python-zstandard

extra:
  recipe-maintainers:
    - rmax
    - xhochy
    - pavelzw
