{% set version = "0.24.2" %}

package:
  name: scikit-learn
  version: {{ version }}

source:
  url: https://github.com/scikit-learn/scikit-learn/archive/{{ version }}.tar.gz
  sha256: 642fb016bfe4bb7539ba6bf4e6dd5a95d2d25638387040b0f5eefdb84a840297

build:
  number: 0
  skip: true  # [py2k]
  script:
    - rm $PREFIX/include/cblas.h  # [not win]
    - del /f %LIBRARY_INC%\cblas.h  # [win]
    # build the C files in parallel. This helps beat the
    # time limit consistently on drone.io
    - {{ PYTHON }} setup.py build_ext -j{{ CPU_COUNT }}
    - {{ PYTHON }} -m pip install . -vv

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]
    - scipy                                  # [build_platform != target_platform]
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - llvm-openmp  # [osx]
  host:
    - python
    - pip
    - cython >=0.28.5
    - libcblas
    - numpy
    - scipy >=0.17.0
    - joblib >=0.11
    - threadpoolctl
  run:
    - python
    - {{ pin_compatible('numpy') }}
    - scipy
    - joblib >=0.11
    - threadpoolctl


# Some tests take alot of memory, and seem to cause segfaults when memory runs out
{% set test_cpus = CPU_COUNT %}  # [not (aarch64 or ppc64le)]
{% set test_cpus = 2 %}  # [ppc64le]
{% set test_cpus = 8 %}  # [aarch64]

{% set tests_to_skip = "_not_a_real_test" %}
# Fixed in 0.22.1 -- https://github.com/scikit-learn/scikit-learn/issues/15774
{% set tests_to_skip = tests_to_skip + " or test_pca_dtype_preservation" %}               # [ppc64le]
# Can fail on aarch64 -- https://github.com/scikit-learn/scikit-learn/issues/15821
{% set tests_to_skip = tests_to_skip + " or test_uniform_grid" %}                         # [aarch64]
# Can fail -- https://github.com/scikit-learn/scikit-learn/issues/15818
{% set tests_to_skip = tests_to_skip + " or test_sag_regressor_computed_correct" %}       # [linux]
# Occasionally fails on aarch64 -- https://github.com/scikit-learn/scikit-learn/issues/15825
{% set tests_to_skip = tests_to_skip + " or test_unreachable_accuracy" %}                 # [aarch64]
# Numerically unstable test numerical difference in test
{% set tests_to_skip = tests_to_skip + " or test_mlp_regressor_dtypes_casting" %}         # [ppc64le]
# https://github.com/scikit-learn/scikit-learn/issues/19111
{% set tests_to_skip = tests_to_skip + " or test_compare_to_ELKI" %}                      # [ppc64le]


test:
  requires:
    - pytest >=3.3.0
    - cython >=0.28.5
    - pytest-xdist
    - pytest-timeout
  imports:
    - sklearn
  commands:
    - set OPENBLAS_NUM_THREADS=1          # [win]
    - set OMP_NUM_THREADS=1               # [win]
    - export OPENBLAS_NUM_THREADS=1       # [not win]
    - export OMP_NUM_THREADS=1            # [not win]
    # Skipping testing in Travis-CI for ppc64le pypy
    - pytest --timeout 300 -n {{ test_cpus }} --verbose --pyargs sklearn -k "not ({{ tests_to_skip }})"    # [not (CI == "travis" and ppc64le and python_impl=="pypy")]

about:
  home: http://scikit-learn.org/
  license: BSD-3-Clause
  license_file: COPYING
  summary: A set of python modules for machine learning and data mining

extra:
  recipe-maintainers:
    - amueller
    - astaric
    - jakirkham
    - ogrisel
    - ocefpaf
    - lesteve
    - jnothman
    - rth
    - adrinjalali
    - glemaitre
    - jeremiedbb
