#### START - Config version naming (right side is default value)
{% set ucx_version = environ.get("UCX_VERSION", "1.7.0dev").lstrip('v') %}
{% set ucx_number = environ.get("UCX_BUILD_NUMBER", 0) %}
{% set ucx_proc_version = environ.get("UCX_PROC_VERSION", "1.0.0") %}
{% set ucx_py_version = environ.get("UCX_PY_VERSION", "0.12a").lstrip('v') + environ.get('VERSION_SUFFIX', '') %}
{% set ucx_py_number = environ.get("UCX_PY_BUILD_NUMBER", 0) %}
{% set cuda_version = '.'.join(environ.get('CUDA_VERSION', '9.2').split('.')[:2]) %}
{% set py_version = environ.get('CONDA_PY', '36') %}
#### END - Config version naming

#### START - Config source commits (right side is default value)
{% set ucx_commit = environ.get("UCX_COMMIT", "430ae7e") %}
{% set ucx_py_commit = environ.get("UCX_PY_COMMIT", "486852e") %}
#### END - Config source commits

{% set ucx_proc_type = "cpu" if cuda_compiler_version == "None" else "gpu" %}

package:
  name: ucx-split

source:
  - git_url: https://github.com/openucx/ucx
    git_rev: {{ ucx_commit }}
    folder: ucx
    patches:
      - ipc-cache-threshold.patch
  - git_url: https://github.com/rapidsai/ucx-py
    git_rev: {{ ucx_py_commit }}
    folder: ucx-py

build:
  skip: true  # [not linux]
  number: 0
  script_env:
    - UCX_VERSION
    - UCX_COMMIT
    - UCX_BUILD_NUMBER
    - UCX_PROC_VERSION
    - UCX_PY_VERSION
    - UCX_PY_COMMIT
    - UCX_PY_BUILD_NUMBER

outputs:
  - name: ucx-proc
    version: {{ ucx_proc_version }}
    build:
      number: 0
      string: "{{ ucx_proc_type }}"
    test:
      commands:
        - exit 0
    about:
      home: https://github.com/conda-forge/ucx-feedstock
      license: BSD-3-Clause
      license_family: BSD
      summary: A meta-package to select CPU or GPU UCX build.

  - name: ucx
    version: "{{ ucx_version }}+g{{ ucx_commit }}"

    build:
      number: {{ ucx_number }}
      string: cuda{{ cuda_version }}_{{ ucx_number }}
      script_env:
        - CUDA_HOME
    requirements:
      build:
        - {{ compiler("c") }}
        - {{ compiler("cxx") }}
        - {{ compiler("cuda") }}         # [cuda_compiler_version != "None"]
        - {{ cdt("libnl") }}
        - {{ cdt("libibcm-devel") }}
        - {{ cdt("libibverbs-devel") }}
        - {{ cdt("librdmacm-devel") }}
        - {{ cdt("numactl-devel") }}
        - automake
        - autoconf
        - libtool
        - libgomp      # [linux and not aarch64]
        - make
        - pkg-config
      host:
      run_constrained:
        - ucx-proc * {{ ucx_proc_type }}
    script: install_ucx.sh
    test:
      commands:
        - test -f "${PREFIX}/bin/ucx_info"
        # Requires driver for GPU test.
        - ${PREFIX}/bin/ucx_info -v         # [cuda_compiler_version == "None"]
    about:
      home: https://github.com/openucx/ucx
      license: BSD-3-Clause
      license_family: BSD
      license_file: ucx/LICENSE
      summary: Unified Communication X.

  - name: ucx-py
    version: "{{ ucx_py_version }}+g{{ ucx_commit }}"
    build:
      number: {{ ucx_py_number }}
      string: py{{ py_version }}_{{ ucx_py_number }}
      skip: true  # [py<36]
      script_env:
        - CUDA_HOME
      ignore_run_exports:
        - cudatoolkit                    # [cuda_compiler_version != "None"]

    requirements:
      build:
        - {{ compiler("c") }}
        - {{ compiler("cxx") }}
        - {{ compiler("cuda") }}         # [cuda_compiler_version != "None"]
        - {{ cdt("libnl") }}
        - {{ cdt("libibcm") }}
        - {{ cdt("libibverbs") }}
        - {{ cdt("librdmacm") }}
        - {{ cdt("numactl") }}
      host:
        - python
        - pip
        - cython >=0.29.14,<3.0.0a0
        - libhwloc
        - ucx
      run:
        - python
        - numpy
        - ucx {{ ucx_version }}+g{{ ucx_commit }}
      run_constrained:
        - ucx-proc * {{ ucx_proc_type }}
    script: install_ucx-py.sh
    test:
      imports:
        - ucp
    about:
      home: https://github.com/rapidsai/ucx-py
      license: BSD-3-Clause
      license_family: BSD
      license_file: ucx-py/LICENSE
      summary: Python bindings for UCX

about:
  home: https://github.com/openucx/ucx
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENSE
  summary: Unified Communication X.

extra:
  recipe-maintainers:
    - Akshay-Venkatesh
    - jakirkham
    - quasiben
    - TomAugspurger
