{% set version = "1.26.2" %}

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

source:
  url: https://github.com/numpy/numpy/releases/download/v{{ version }}/numpy-{{ version }}.tar.gz
  sha256: f65738447676ab5777f11e6bbbdb8ce11b785e105f690bc45966574816b6d3ea  
  patches:                                                # [blas_impl == "mkl" or s390x]
    - patches/0003-intel_init_mkl.patch                   # [blas_impl == "mkl"]
    - patches/0004-Partially-revert-function-blocklisting-for-glibc-lt-2.18.patch # [s390x]

build:
  number: 0
  # numpy 1.26 no longer supports Python 3.8: https://numpy.org/devdocs/release/1.26.0-notes.html
  # "This release supports Python versions 3.9-3.12"
  skip: True  # [(blas_impl == 'openblas' and win)]
  skip: True  # [py<39 or py>=313]
  force_use_keys:
    - python

requirements:
  build:
    - patch     # [(blas_impl == "mkl" or s390x) and not win]
    - m2-patch  # [(blas_impl == "mkl") and win]

outputs:
  # this one has all the actual contents
  - name: numpy-base
    script: install_base.sh   # [unix]
    script: install_base.bat  # [win]
    build:
      entry_points:
        - f2py = numpy.f2py.f2py2e:main
      missing_dso_whitelist:  # [s390x]
        - $RPATH/ld64.so.1    # [s390x]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - armpl  # [aarch64]        
        - ninja-base
        - pkg-config
      host:
        - python
        - pip
        - cython >=0.29.34,<3.1
        - python-build
        # dependencies of vendored meson-python
        - pyproject-metadata >=0.7.1
        - tomli >=1.0.0         # [py<311]
        - setuptools >=60.0     # [py>=312]
        - colorama              # [win]
        # blas
        - mkl-devel  {{ mkl }}  # [blas_impl == "mkl"]
        - openblas-devel {{ openblas }}  # [blas_impl == "openblas"]
      run:
        - python
  
  # When building out the initial package set for a new Python version / MKL version the
  # recommendation is to build numpy-base but not numpy, then build
  # mkl_fft and mkl_random, and then numpy.
  # If only_build_numpy_base: "yes build numpy-base only; otherwise build all the outputs.
  {% if only_build_numpy_base != 'yes' %}
  # numpy is a metapackage that may include mkl_fft and mkl_random both of
  # which require numpy-base to build
  - name: numpy
    build:
      missing_dso_whitelist:  # [s390x]
        - $RPATH/ld64.so.1    # [s390x]
    requirements:
      build:
        # for runtime alignment
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - armpl  # [aarch64]
      host:
        - python
        # these import blas metapackages to ensure consistency with downstream libs that also use blas
        - mkl-devel  {{ mkl }}  # [blas_impl == 'mkl']
        - openblas-devel {{ openblas }}  # [blas_impl == 'openblas']
      run:
        - python
        - {{ pin_subpackage('numpy-base', exact=True) }}
        # openblas or mkl runtime included with run_exports
        - mkl_fft  # [blas_impl == 'mkl']
        - mkl_random # [blas_impl == 'mkl' and (not win or vc>=14)]
    {% endif %}

    {% set tests_to_skip = "_not_a_real_test" %}

    # https://github.com/numpy/numpy/issues/3858 - could be related
    {% set tests_to_skip = tests_to_skip + " or test_big_arrays" %}  # [s390x]
    # https://github.com/numpy/numpy/issues/16046
    {% set tests_to_skip = tests_to_skip + " or test_gcd_overflow" %}  # [s390x]
    # skip simd tests because vxe2 feature is not detected when running from prefect
    {% set tests_to_skip = tests_to_skip + " or test_features" %}  # [s390x]   

    test:
      requires:
        - pip
        - pytest >=7.4.0
        - pytest-cov >=4.1.0
        - pytest-xdist
        - hypothesis >=6.81.1
        - pytz >=2023.3
        - {{ compiler('c') }}  # [not osx]
        - {{ compiler('cxx') }}  # [not osx]
        - {{ compiler('fortran') }}  # [not osx]
        - nomkl  # [x86 and blas_impl != 'mkl']
        - typing-extensions >=4.2.0
        - mypy >=1.5.1
        - cffi  # [py<310]
        - charset-normalizer
        - meson
      commands:
        - f2py -h
        - python -c "import numpy; numpy.show_config()"
        - export OPENBLAS_NUM_THREADS=1  # [unix]
        - set OPENBLAS_NUM_THREADS=1  # [win]
        - export CPU_COUNT=4  # [linux and ppc64le]
        - pytest -vv --pyargs numpy -k "not ({{ tests_to_skip }})" --durations=50 --durations-min=1.0
      imports:
        - numpy
        - numpy.core.multiarray
        - numpy.core.numeric
        - numpy.core.umath
        - numpy.linalg.lapack_lite
        - numpy.random.mtrand
        # from numpy/tests/test_public_api.py
        - numpy.array_api
        - numpy.array_api.linalg
        - numpy.ctypeslib
        - numpy.doc
        - numpy.doc.constants
        - numpy.doc.ufuncs
        - numpy.dtypes
        - numpy.exceptions
        - numpy.f2py
        - numpy.fft
        - numpy.lib
        - numpy.lib.format  # was this meant to be public?
        - numpy.lib.mixins
        - numpy.lib.recfunctions
        - numpy.lib.scimath
        - numpy.lib.stride_tricks
        - numpy.linalg
        - numpy.ma
        - numpy.ma.extras
        - numpy.ma.mrecords
        - numpy.matlib
        - numpy.polynomial
        - numpy.polynomial.chebyshev
        - numpy.polynomial.hermite
        - numpy.polynomial.hermite_e
        - numpy.polynomial.laguerre
        - numpy.polynomial.legendre
        - numpy.polynomial.polynomial
        - numpy.random
        - numpy.testing
        - numpy.testing.overrides
        - numpy.typing
        - numpy.typing.mypy_plugin
        - numpy.version  # Should be removed for NumPy 2.0

about:
  home: https://numpy.org/
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENSE.txt
  summary: Array processing for numbers, strings, records, and objects.
  description: |
    NumPy is the fundamental package needed for scientific computing with Python.
  doc_url: https://numpy.org/doc/stable/reference/
  dev_url: https://github.com/numpy/numpy

extra:
  recipe-maintainers:
    - jakirkham
    - msarahan
    - pelson
    - rgommers
    - ocefpaf
    - chenghlee 
