{% set version = "1.25.0" %}

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

source:
  url: https://github.com/numpy/numpy/releases/download/v{{ version }}/numpy-{{ version }}.tar.gz
  sha256: f1accae9a28dc3cda46a91de86acf69de0d1b5f4edd44a9b0c3ceb8036dfff19  
  patches:
    - patches/0001-Obtain-and-prefer-custom-gfortran-from-env-variable.patch
    - patches/0002-intel_mkl-version.patch              # [blas_impl == "mkl"]
    - patches/0003-intel_init_mkl.patch                 # [blas_impl == "mkl"]
    - patches/0004-disable-autorun-for-cmd-test.patch   # [win]
    - patches/0005-array_coercion_fix.patch             # [blas_impl == "mkl" and win]
    - patches/0006-popcnt_fix.patch                     # [blas_impl == "mkl" and win]
    - patches/0007-enable-meson-build.patch             # [py>=312] https://github.com/numpy/numpy/blob/v1.25.0/building_with_meson.md

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

requirements:
  build:
    - patch     # [not win]
    - m2-patch  # [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]
      host:
        - python
        - pip
        - cython >=0.29.34,<3.0
        - setuptools <60.0.0    # [py<=311]
        - wheel                 # [py<=311]
        - meson-python >=0.10.0 # [py>=312]
        - meson >=1.1.0         # [py>=312]
        - 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' %}
    test:
      commands:
        - test -e $SP_DIR/numpy/distutils/site.cfg     # [unix and py<=311]
        - IF NOT EXIST %SP_DIR%\numpy\distutils\site.cfg exit 1  # [win and py<=311]

  # 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
        - cython >=0.29.34,<3.0
        - setuptools <60.0.0    # [py<=311]
        - wheel                 # [py<=311]
        - meson-python >=0.10.0 # [py>=312]
        - meson >=1.1.0         # [py>=312]
        # 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" %}

    # Flawed test when using MKL
    # https://github.com/numpy/numpy/issues/16769
    {% set tests_to_skip = tests_to_skip + " or test_overrides" %}  # [blas_impl == 'mkl']
    # https://github.com/numpy/numpy/issues/15243
    {% set tests_to_skip = tests_to_skip + " or test_loss_of_precision" %}  # [s390x]
    # https://github.com/numpy/numpy/issues/3858 - could be related
    {% set tests_to_skip = tests_to_skip + " or test_big_arrays" %}  # [s390x]

    #skip simd tests because  -mno-vx option for s390
    {% set tests_to_skip = tests_to_skip + " or test_features" %}  # [s390x]

    # It should be fixed by https://github.com/numpy/numpy/issues/20426
    # but it still fails on some platforms.
    {% set tests_to_skip = tests_to_skip + " or test_new_policy" %}   # [s390x]
    # ?
    {% set tests_to_skip = tests_to_skip + " or test_gcd_overflow" %}  # [s390x]
    
    test:
      requires:
        - pip     # force installation or `test_api_importable` will fail
        - pytz
        - pytest
        - pytest-cov
        - pytest-xdist
        - hypothesis >=6.29.3
        - pytz >=2021.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 >=0.981
        - cffi  # [py<310]
      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 -vvv --pyargs numpy -k "not ({{ tests_to_skip }})" --durations=0
      imports:
        - numpy
        - numpy.core.multiarray
        - numpy.core.numeric
        - numpy.core.umath
        - numpy.linalg.lapack_lite
        - numpy.random.mtrand

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 
