{% set version = "3.3.0" %}
{% set build = 0 %}

# mpi must be defined for conda-smithy lint
{% set mpi = mpi or 'nompi' %}

{% if mpi == 'nompi' %}
# prefer nompi builds via a build number offset
{% set build = build + 100 %}
{% endif %}

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

source:
  url: https://github.com/h5py/h5py/archive/{{ version }}.tar.gz
  sha256: d34e362d6e278d583a8fbcdd6628bdb2af4cfa4077d373d767d79cd7911af2b1
  patches:
    # override setup.py specified minimum compatible numpy versions
    # we take care of those via numpy pinning below
    - adjust-minimum-numpy-run-versions.patch
    - osx-arm64.diff    # [osx and arm64]
    - osx-arm64-hdf5.diff    # [osx and arm64]

build:
  skip: true  # [py<=36]
  number: {{ build }}
  {% if mpi != 'nompi' %}
  {% set mpi_prefix = "mpi_" + mpi %}
  {% else %}
  {% set mpi_prefix = "nompi" %}
  {% endif %}
  # add build string so packages can depend on
  # mpi or nompi variants
  # dependencies:
  # `pkg * mpi_mpich_*` for mpich
  # `hdf5 * mpi_*` for any mpi
  # `hdf5 * nompi_*` for no mpi
  string: {{ mpi_prefix }}_py{{ py }}h{{ PKG_HASH }}_{{ build }}
  script_env:
    - HDF5_HAS_ROS3=1  # [osx and arm64]

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") }}
    - {{ mpi }}  # [mpi == 'openmpi' and build_platform != target_platform]
  host:
    - python
    - pip
    - numpy
    - {{ mpi }}  # [mpi != 'nompi']
    - mpi4py >=3.0  # [mpi != 'nompi']
    # need to list hdf5 twice to get version pinning from conda_build_config
    # and build pinning from {{ mpi_prefix }}
    - hdf5
    - hdf5 * {{ mpi_prefix }}_*
    - cython >=0.29.0  # [py<38]
    - cython >=0.29.14  # [py>=38]
    - pkgconfig
  run:
    - python
    - cached-property
    - {{ pin_compatible('numpy') }}
    - {{ mpi }}  # [mpi != 'nompi']
    - mpi4py >=3.0  # [mpi != 'nompi']
    # hdf5 >=1.10.4 has run_exports
    - hdf5
    - pyreadline  # [win]

test:
  imports:
    - h5py
  commands:
    - pip check
  requires:
    - pip
    - pytest
    - pytest-mpi

about:
  home: http://www.h5py.org/
  license: BSD-3-Clause
  license_file: licenses/license.txt
  summary: Read and write HDF5 files from Python
  dev_url: https://github.com/h5py/h5py

extra:
  recipe-maintainers:
    - jakirkham
    - tacaswell
    - ocefpaf
    - minrk
    - scopatz
