{% set build_variant = environ.get('PYTORCH_BUILD_VARIANT', 'cuda') %}
{% set cross_compile_arm64 = environ.get('CROSS_COMPILE_ARM64', 0) %}

package:
  name: pytorch
  version: "{{ environ.get('PYTORCH_BUILD_VERSION') }}"

source:
  path: "{{ environ.get('PYTORCH_GITHUB_ROOT_DIR') }}"

requirements:
  build:
    - cmake
    - {{ compiler('c') }} # [win]

  host:
    - python
    - setuptools
    - pyyaml
    {% if cross_compile_arm64 == 0 %}
    - mkl-include # [x86_64]
    - mkl=2020.2 # [x86_64 and (not win or py <= 39)]
    - mkl=2021.4 # [x86_64 and win and py >= 310]
    {% endif %}
    - typing_extensions
    - dataclasses # [py36]
    - ninja
    - libuv # [win]
    - libuv # [unix]
    - pkg-config # [unix]
    - numpy=1.19 # [py <= 39]
    - numpy>=1.21.2 # [py >= 310]
    - openssl=1.1.1l # [py >= 310 and linux]
{{ environ.get('PYTORCH_LLVM_PACKAGE', '    - llvmdev=9') }}
{{ environ.get('MAGMA_PACKAGE', '') }}

  run:
    - python
    {% if cross_compile_arm64 == 0 %}
    - mkl >=2018 # [x86_64]
    {% endif %}
    - dataclasses # [py36]
    - libuv # [win]
    - intel-openmp # [win]
    - typing_extensions
    {% if cross_compile_arm64 == 0 %}
    - blas * mkl
    {% endif %}
    - pytorch-mutex 1.0 {{ build_variant }}  # [not osx ]
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}

  {% if build_variant == 'cpu' %}
  run_constrained:
    - cpuonly
  {% elif not osx %}
  run_constrained:
     - cpuonly <0
  {% endif %}

build:
  number: {{ environ.get('PYTORCH_BUILD_NUMBER', '1') }}
  detect_binary_files_with_prefix: False
  string: "{{ environ.get('PYTORCH_BUILD_STRING') }}"
  script_env:
    - BUILD_SPLIT_CUDA
    - CUDA_VERSION
    - CUDNN_VERSION
    - CONDA_CUDATOOLKIT_CONSTRAINT
    - USE_CUDA
    - CMAKE_ARGS
    - EXTRA_CAFFE2_CMAKE_FLAGS
    - DEVELOPER_DIR
    - DEBUG
    - USE_FBGEMM
    - USE_GLOO_WITH_OPENSSL # [unix]
    - USE_SCCACHE # [win]
    - USE_DISTRIBUTED # [unix]
    - CMAKE_OSX_ARCHITECTURES # [unix]
    - USE_MKLDNN # [unix]
    - USE_NNPACK # [unix]
    - USE_QNNPACK # [unix]
    - BUILD_TEST # [unix]
    - USE_PYTORCH_METAL_EXPORT # [osx]
    - USE_COREML_DELEGATE # [osx]

test:
 imports:
    - torch

about:
  home: http://pytorch.org/
  license: BSD 3-Clause
  license_family: BSD
  license_file: LICENSE
  summary: PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.
