{% set name = "scikit-learn" %}
{% set version = "1.2.2" %}
{% set sha256 = "992694e21ce4285aab71b09939d3ed7e5ddb41b8803eb98e10aaba927b74bdf1" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://github.com/{{ name }}/{{ name }}/archive/{{ version }}.tar.gz
  sha256: {{ sha256 }} 

build:
  number: 1
  skip: true  # [py<38]
  script: 
    - {{ PYTHON }} -m pip install --no-deps --ignore-installed . -vv
  missing_dso_whitelist:
    - '*/libc++.1.dylib'  # [osx]
    - '*/libomp.dylib'    # [osx]

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - llvm-openmp    # [osx]
  host:
    # Host dependencies are pinned to last build
    - python
    - cython 0.29.33
    - llvm-openmp 14.0.6  # [osx]
    - numpy   1.21   # [py<311]
    - numpy   1.23   # [py>=311]
    - pip
    - scipy 1.9.3   # [py<311]
    - scipy 1.10.0  # [py>=311]
    - setuptools
    - threadpoolctl 2.2.0
    - wheel
  run:
    - python
    - joblib >=1.1.1
    - {{ pin_compatible('numpy') }}
    - scipy >=1.3.2
    - threadpoolctl >=2.0.0
    - _openmp_mutex  # [linux]
  run_constrained:
    # intel-openmp 2023.1 and llvm-openmp 14.0.6 appear not be compatible
    # leading to segfault in test_pairwise_distances_reduction.py::test_sqeuclidean_row_norms[42-float64-8-5-100]
    - intel-openmp <2023.1  # [osx and x86_64]

# Some tests take alot of memory, and seem to cause segfaults when memory runs out
{% set test_cpus = 1 %}

{% set tests_to_skip = "_not_a_real_test" %}
# https://github.com/scikit-learn/scikit-learn/issues/20335
{% set tests_to_skip = tests_to_skip + " or test_loadings_converges" %}
# Numerically unstable test numerical difference in test
{% set tests_to_skip = tests_to_skip + " or test_mlp_regressor_dtypes_casting" %}               # [ppc64le]
{% set tests_to_skip = tests_to_skip + " or test_ridge_regression_check_arguments_validity" %}  # [osx]

test:
  requires:
    - cython >=0.29.24
    - pip
    - pytest >=5.3.1
    - pytest-timeout
    - pytest-xdist
  imports:
    - sklearn
    - sklearn.cluster
    - sklearn.datasets
    - sklearn.decomposition
    - sklearn.ensemble
    - sklearn.feature_extraction
    - sklearn.linear_model
    - sklearn.manifold
    - sklearn.metrics
    - sklearn.neighbors
    - sklearn.tree
    - sklearn.utils
    - sklearn.svm
  commands:
    - pip check
    - 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]
    - pytest --timeout 300 -n {{ test_cpus }} --verbose --pyargs sklearn -k "not ({{ tests_to_skip }})"

about:
  home: https://scikit-learn.org/
  license: BSD-3-Clause
  license_file: COPYING
  license_family: BSD
  summary: A set of python modules for machine learning and data mining
  description: |
    Scikit-learn is an open source machine learning library that supports supervised and unsupervised learning. 
    It also provides various tools for model fitting, data preprocessing, model selection, model evaluation, 
    and many other utilities.
  doc_url: https://scikit-learn.org/dev/user_guide.html
  dev_url: https://github.com/scikit-learn/scikit-learn

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