{% set version = "1.17.5" %}
{% set buildnumber = 1 %}
{% set major = '.'.join(version.split('.')[0:2]) %}

{% set mkl_fft_version = '1.1.0' %}
{% set mkl_fft_buildnumber = 0 %}

{% set mkl_random_version = '1.1.0' %}
{% set mkl_random_buildnumber = 0 %}

### If you change the iccver here, you must also set the path correctly in build.sh / bld.bat!!!
{% set iccver = "16.0.3" %}    [unix or py3k]
{% set iccver = "13.1.5" %}    [win and py27]

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

source:
    - git_url: https://github.com/numpy/numpy
      git_tag: v{{version}}
      patches:
        - v{{major}}-patches/intel_mkl-version.patch         [not nomkl]
        - v{{major}}-patches/osx-dist.patch                  [osx]
        - v{{major}}-patches/intel_use_mkl_fft.patch         [not nomkl]
        - v{{major}}-patches/intel_distribution.patch
        - v{{major}}-patches/intel_umath_optimizations.patch [not nomkl]
        - v{{major}}-patches/intel_mkl_mem_all.patch         [not nomkl]
        - v{{major}}-patches/intel_init_mkl.patch            [not nomkl]
        - v{{major}}-patches/intel_mkl_random.patch          [not nomkl]
        - v{{major}}-patches/intel_setup_add_whl_deps.patch  [not nomkl]
    - git_url: https://github.com/IntelPython/mkl_fft.git
      # git_tag: v{{mkl_fft_version}}
      git_rev: aeb56b700353365904d6b8cf1c9cb0e2c5a9e90a
      folder: mkl_fft
    - git_url: https://github.com/IntelPython/mkl_random.git
      git_tag: v{{mkl_random_version}}
      folder: mkl_random


build:
    number: {{buildnumber}}
    features:
      - nomkl                   [x86 and nomkl]
    force_use_keys:
      - python


outputs:
    - name: numpy-base
      script: install_base.sh   # [unix]
      script: install_base.bat  # [win]
      requirements:
        host:
          - cython
          - python
          - setuptools
          - wheel
          - mkl-devel >=2019.0.0 [not nomkl]
          - mkl-service >=2.1.0 [not nomkl]
          - intel-libpatch   # [linux]
        run:
          - python
          - icc_rt >={{iccver}}
          - intelpython >=2019.0
          - mkl                  [not nomkl]
          - tbb4py               [not nomkl] # mkl depends on tbb, numpy adds Python specifics
          - mkl-service >=2.1.0 [not nomkl]
  
      test:
        commands:
          - test -e $SP_DIR/numpy/distutils/site.cfg     # [unix]
          - IF NOT EXIST %SP_DIR%\numpy\distutils\site.cfg exit 1  # [win]

      about:
        home: http://numpy.scipy.org/
        license: BSD 3-Clause
        license_file: LICENSE.txt

    - name: numpy-devel
      build:
        run_exports:
          - {{ pin_subpackage('numpy', min_pin='x.x', max_pin='x.x') }}
      script: copy_intel_tester.sh  # [unix]
      script: copy_intel_tester.bat # [win]             
      requirements:
        host:
          - python
          # these import blas metapackages to ensure consistency with downstream libs that also use blas
          - mkl-devel    # [not nomkl]
        run:
          - python
          - {{ pin_subpackage('numpy-base', exact=True) }}
          - icc_rt >={{iccver}}
          - intelpython >=2019.0
          - tbb4py  [not nomkl]

    - name: numpy
      requirements:
        host:
          - python
        run:
          - python
          - intelpython >=2019.0
          - {{ pin_subpackage('numpy-base', exact=True) }}
          - {{ pin_subpackage('mkl_fft') }}  # [not nomkl]
          - {{ pin_subpackage('mkl_random') }}  # [not nomkl]

      test:
        files:
          - intel_tester_config.py
        commands:
          - python -c "import numpy as np; print(np.__mkl_version__)"
          - python -c "from intel_tester import test_routine; test_routine.test_exec()"
          - f2py -h                # [unix]
        requires:
          - intel_tester
          - pytest
        imports:
          - numpy
          - numpy.linalg.lapack_lite

      about:
        home: http://numpy.scipy.org/
        license: BSD 3-Clause
        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://docs.scipy.org/doc/numpy-1.17.0/reference/
        dev_url: https://github.com/numpy/numpy
        dev_source_url: https://github.com/numpy/numpy/tree/master/doc

    - name: mkl_fft
      version: {{ mkl_fft_version }}
      script: install_mkl_fft.bat  # [win]
      script: install_mkl_fft.sh   # [not win]
      source:
        git_url: https://github.com/IntelPython/mkl_fft.git
        git_tag: v{{mkl_fft_version}}

      build:
         number: {{ mkl_fft_buildnumber }}

      requirements:
        host:
          - python
          - setuptools
          - mkl-devel  # [not nomkl]
          - icc_rt >={{iccver}}
          - cython
          - numpy-base {{ numpy }}
          - wheel
          - intel-libpatch          # [linux]
        run:
          - python
          - {{ pin_compatible("numpy-base") }}
          - mkl   # [not nomkl]
          - icc_rt >={{iccver}}
          - intelpython >=2019.0

      test:
        commands:
          - nosetests -v mkl_fft
        requires:
          - nose
        imports:
          - mkl_fft
          - mkl_fft._numpy_fft
          - mkl_fft._scipy_fft

      about:
        home: http://github.com/IntelPython/mkl_fft
        license: BSD
        license_file: LICENSE.txt
        summary: NumPy-based implementation of Fast Fourier Transform using Intel(R) Math Kernel Library (Intel(R) MKL).

    - name: mkl_random
      version: {{ mkl_random_version }}
      script: install_mkl_random.bat  # [win]
      script: install_mkl_random.sh   # [not win]
      source:
        git_url: https://github.com/IntelPython/mkl_random.git
        git_tag: v{{mkl_random_version}}

      build:
        number: {{ mkl_random_buildnumber }}

      requirements:
        build:
          # pass
        host:
          - python
          - setuptools
          - mkl-devel  # [not nomkl]
          - icc_rt >={{iccver}}
          - cython
          - numpy-base {{ numpy }}
          - wheel
          - intel-libpatch          # [linux]
        run:
          - python
          - {{ pin_compatible("numpy-base") }}
          - mkl   # [not nomkl]
          - icc_rt >={{iccver}}
          - intelpython >=2019.0

      test:
        commands:
          - nosetests -v mkl_random
        requires:
          - nose
        imports:
          - mkl_random
          - mkl_random.mklrand

      about:
        home: http://github.com/IntelPython/mkl_random
        license: BSD
        license_file: LICENSE.txt
        summary: NumPy-based implementation of random number generation sampling using Intel(R) Math Kernel Library (Intel(R) MKL), mirroring numpy.random, but exposing all choices of sampling algorithms available in Intel(R) MKL.
