{% set name = "safetensors" %}
{% set version = "0.4.0" %}

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

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

build:
  number: 0
  skip: True  # [py<38 or s390x]
  script: {{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vv

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('rust') }}
  host:
    - pip
    - python
    - wheel
    - maturin 1.3.0
  run:
    - python
  run_constrained:
    - numpy >= 1.21.6
    - tensorflow >= 2.11
    - jax >= 0.3.25
    - jaxlib >= 0.3.25
    - flax >= 0.6.3

test:
  imports:
    - safetensors
  requires:
    - pip
# Skip tests on ppc64le/python 3.11; missing pytorch.
{% if not (ppc64le and py>310) %}
    - numpy
    - h5py >= 3.7.0
    - huggingface_hub >= 0.12.1
    - setuptools-rust >= 1.5.2
    - pytest >= 7.2.0
    - pytest-benchmark >= 4.0.0
    - hypothesis >= 6.70.2
    - pytorch >= 1.10
  source_files:
    - bindings/python/tests
{% endif %}
  commands:
    - pip check
    # Excluded test modules:
    # test_flax_comparison.py: Missing flax on defaults
    # test_paddle_comparison.py: Missing paddlepaddle on defaults
    # test_tf_comparison.py: Adding tensorflow causes pip check to fail
    - cd bindings/python  # [not (ppc64le and py>310)]
    - pytest -v tests --ignore=tests/test_tf_comparison.py --ignore=tests/test_paddle_comparison.py --ignore=tests/test_flax_comparison.py  # [not (ppc64le and py>310)]

about:
  home: https://github.com/huggingface/safetensors
  dev_url: https://github.com/huggingface/safetensors
  doc_url: https://huggingface.co/docs/safetensors/index
  summary: Fast and Safe Tensor serialization
  description: |
    Simple, safe way to store and distribute tensors.
  license: Apache-2.0
  license_family: Apache
  license_file: LICENSE

extra:
  recipe-maintainers:
    - jan-janssen
