{% set build_variant = environ.get('CONDA_BUILD_VARIANT', 'cpu') %}
package:
  name: torchaudio
  version: "{{ environ.get('BUILD_VERSION', '0.0.0') }}"

source:
  path: "{{ environ.get('SOURCE_ROOT_DIR', '../..') }}"

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

  host:
    - python
    - setuptools
    - pkg-config  # [not win]
    - cmake
    - ninja
    - pytorch-mutex 1.0 {{ build_variant }}  # [not osx ]
    {{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }}
    {{ environ.get('CONDA_EXTRA_BUILD_CONSTRAINT', '') }}
    {{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}

  run:
    - python
    - numpy
    - pytorch-mutex 1.0 {{ build_variant }}  # [not osx ]
    {{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
    {{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}

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

build:
  string: py{{py}}_{{ environ.get('CU_VERSION', 'cpu') }}
  script_env:
    - BUILD_VERSION
    - USE_CUDA
    - CUDA_HOME
    - TORCH_CUDA_ARCH_LIST
    - USE_FFMPEG
    - USE_OPENMP
    - MACOSX_DEPLOYMENT_TARGET

test:
  imports:
    - torchaudio
    - torchaudio.io
    - torchaudio.datasets
    - torchaudio.kaldi_io
    - torchaudio.sox_effects
    - torchaudio.transforms

  source_files:
    - test

  requires:
    - pytest
    # Ideally we would test this, but conda doesn't provide librosa
    # - librosa >=0.4.3
    - scipy
    - pytorch-mutex 1.0 {{ build_variant }}  # [not osx ]

about:
  home: https://github.com/pytorch/audio
  license: BSD
  license_file: LICENSE
  summary: 'simple audio I/O for pytorch'
