{% set name = "xgboost" %}
{% set version = "1.3.0" %}

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

source:
  # we have to use git urls here to get the submodules needed for the
  # build
  git_url: https://github.com/dmlc/xgboost
  git_tag: v1.3.0
  patches:
    # xgboost patches
    - 0001-conda-Unbundle-libxgboost.-dll-dylib-so.patch
    - 0002-Fix-R-package-PKGROOT.patch

build:
  number: 2

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - git                    # [not win]
    - m2-git                 # [win]
    - cmake
    - make
    - llvm-openmp  # [osx]
    - ninja  # [win]
  host:
    - llvm-openmp  # [osx]

outputs:
  - name: libxgboost
    script: install-libxgboost.sh  # [not win]
    script: install-win-wrapper.bat  # [win]
    build:
      activate_in_script: True
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - git
        - cmake
        - make
        - llvm-openmp  # [osx]
      host:
        - llvm-openmp  # [osx]
      run:
        - llvm-openmp  # [osx]

  - name: _py-xgboost-mutex
    version: 2.0
    build:
      string: cpu_0

  - name: py-xgboost
    script: install-py-xgboost.sh  # [not win]
    script: install-win-wrapper.bat  # [win]
    requirements:
      host:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - python
        - setuptools
        - pip
      run:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - {{ pin_subpackage('_py-xgboost-mutex', exact=True) }}
        - python
        - numpy
        - scipy
        - scikit-learn
    test:
      script: test-py-xgboost.py
      imports:
        - xgboost

  - name: py-xgboost-cpu
    requirements:
      host:
        - python
        - {{ pin_subpackage('py-xgboost', exact=True) }}
      run:
        - python
        - {{ pin_subpackage('py-xgboost', exact=True) }}

  - name: xgboost
    requirements:
      host:
        - python
        # we install llvm-opnemp here to convince conda to
        # install llvm-openmp in the top-level host env above
        - llvm-openmp  # [osx]
      run:
        - python
        - {{ pin_subpackage('py-xgboost', exact=True) }}

  - name: _r-xgboost-mutex
    version: 2.0
    build:
      string: cpu_0

  - name: r-xgboost
    script: install-r-xgboost.sh  # [not win]
    script: install-r-xgboost.bat  # [win]
    build:
      rpaths:
        - lib/R/lib
    requirements:
      build:
        - {{ compiler('m2w64_c') }}          # [win]
        - {{ compiler('m2w64_cxx') }}        # [win]
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - llvm-openmp            # [osx]
        - git                    
        - make                   # [not win]
        - posix                  # [win]
        - cmake
        - ninja  # [win]
      host:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - r-base
        - llvm-openmp  # [osx]
        - r-matrix
        - r-data.table
        - r-magrittr
        - r-stringi
        - r-knitr
      run:
        - {{ pin_subpackage('libxgboost', exact=True) }}
        - {{ pin_subpackage('_r-xgboost-mutex', exact=True) }}
        - llvm-openmp  # [osx]
        - r-base
        - r-matrix
        - r-data.table
        - r-magrittr
        - r-stringi
    test:
      files:
        - test-r-xgboost.r
      commands:
        - Rscript test-r-xgboost.r

  - name: r-xgboost-cpu
    requirements:
      host:
        - r-base
      run:
        - r-base
        - {{ pin_subpackage('r-xgboost', exact=True) }}

about:
  home: https://github.com/dmlc/xgboost
  license: Apache-2.0
  license_file: LICENSE
  summary: |
    Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for
    Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Flink
    and DataFlow
  description: |
    XGBoost is an optimized distributed gradient boosting library designed to be highly efficient,
    flexible and portable. It implements machine learning algorithms under the Gradient Boosting
    framework. XGBoost provides a parallel tree boosting (also known as GBDT, GBM) that solve many
    data science problems in a fast and accurate way. The same code runs on major distributed
    environment (Hadoop, SGE, MPI) and can solve problems beyond billions of examples.
  doc_url: https://xgboost.readthedocs.io/
  dev_url: https://github.com/dmlc/xgboost/

extra:
  feedstock-name: xgboost
  recipe-maintainers:
    - aldanor
    - jakirkham
    - ksangeek
    - xhochy
