{% set version = "2.12.0" %}
{% set major_minor = version.rsplit('.', 1)[0] %}

# This is the recipe for the "mkl", "eigen" and "gpu" variants of tensorflow-base
package:
  name: tensorflow-base
  version: {{ version }}

source:
  fn: tensorflow-{{ version }}.tar.gz
  url: https://github.com/tensorflow/tensorflow/archive/v{{ version }}.tar.gz
  sha256: c030cb1905bff1d2446615992aad8d8d85cbe90c4fb625cee458c63bf466bc8e
  patches:
    - patches/0101-include-c-and-cc-headers.patch                   # [unix]
    - patches/0103-BUILD-changes-for-external-sqlite-package.patch  # [linux]
    - patches/0107-do-not-hardcode-ca-cert-location.patch           # [unix]
    # gpu specific patches
    - patches/0201-add-additional-cuda-rpaths.patch                 # [linux and (tflow_variant == 'gpu')]
    - patches/0203-choose-cuda-runtime-110-inc.patch                # [linux and (tflow_variant == 'gpu')]

build:
  number: 0
  skip: True  # [not x86_64 and not (linux and aarch64)]
  skip: True  # [win and vc<14]
  skip: True  # [py<38]
  string: {{ tflow_variant }}_py{{ CONDA_PY }}h{{PKG_HASH}}_{{ PKG_BUILDNUM }}
  entry_points:
    - toco_from_protos = tensorflow.lite.toco.python.toco_from_protos:main
    - tflite_convert = tensorflow.lite.python.tflite_convert:main
    - toco = tensorflow.lite.python.tflite_convert:main
    - saved_model_cli = tensorflow.python.tools.saved_model_cli:main
    # The tensorboard package adds this entry point.
    # - tensorboard = tensorboard.main:run_main
    - tf_upgrade_v2 = tensorflow.tools.compatibility.tf_upgrade_v2_main:main
    - estimator_ckpt_converter = tensorflow_estimator.python.estimator.tools.checkpoint_converter:main

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - git
    - patch  # [unix]
    - m2-patch  # [win]
    - m2-coreutils  # [win]
    # required here for all OS's, and ALSO below for windows
    - bazel >=5.2.0
    - aws-sdk-cpp

  host:
    # for cython compiler
    - cython
    - nasm  # [x86]
    # conda build requirements for .sh scripts on win
    - posix  # [win]
    - m2-patch  # [win]
    - bazel >=5.2.0    # [win]
    - packaging
    - python
    - pip
    - setuptools
    - wheel
    - libcurl
    - curl  # [win]
    - unzip  # [not win]
    - zip  # [not win]
    - m2-unzip  # [win]
    - m2-zip  # [win]
    - m2-perl  # [win]
    - nsync
    # requirements specified by the package itself
    - astor >=0.7.1
    - dill >=0.3.1.1
    - giflib
    - grpc-cpp
    - flatbuffers 2.0
    - icu
    - jpeg
    - libpng
    - libprotobuf
    - openssl
    - pybind11
    - sqlite
    - snappy
    - zlib
    - requests
    - absl-py 1.3.0
    - astunparse 1.6.3
    - python-flatbuffers 2.0
    - gast 0.4.0
    - google-pasta >=0.1.1
    - grpcio >=1.24.3,<2.0
    - h5py >=2.9.0
    - numpy 1.22
    - opt_einsum >=2.3.2
    # build only requirement, doesn't need a run dep below
    - protobuf >=3.20.3,<5.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5
    # build only requirement, doesn't need a run dep below
    - scipy 1.7.3  # [py<311]
    - scipy 1.9.3  # [py>=311]
    - six >=1.15.0
    - typing_extensions >=3.7.4
    # build only requirement, doesn't need a run dep below
    - swig
    - termcolor >=1.1.0
    - wrapt >=1.11.2,<1.15
    ###########################################################################
    # GPU requirements
    ###########################################################################
    - cudatoolkit {{ cudatoolkit }}*  # [tflow_variant == 'gpu']
    - cudnn {{ cudnn }}*  # [tflow_variant == 'gpu']
    - cupti  # [not win and tflow_variant == 'gpu']

  run:
    - numpy >=1.22,<1.24
    - scipy >=1.7.3,<2
    - packaging
    - absl-py >=1.0.0
    - astunparse >=1.6.3
    - flatbuffers >=2.0
    - gast 0.4.0
    - google-pasta >=0.1.1
    - grpcio >=1.24.3,<2.0
    - h5py >=2.9.0
    - keras {{ major_minor }}.*
    - opt_einsum >=2.3.2
    - python
    - python-flatbuffers >=2.0
    - setuptools
    - requests
    - six >=1.12.0
    - tensorboard {{ major_minor }}.*
    - tensorflow-estimator {{ major_minor }}.*
    - termcolor >=1.1.0
    - typing_extensions >=3.6.6
    - wrapt >=1.11.2
    # To stop the compiler pulling in an openmp implementation itself
    - _openmp_mutex  # [linux and aarch64]
    ###########################################################################
    # GPU requirements
    ###########################################################################
    - cudatoolkit {{ cudatoolkit }}*  # [tflow_variant == 'gpu']
    - cudnn {{ cudnn }}*  # [tflow_variant == 'gpu']
    - cupti  # [not win and tflow_variant == 'gpu']

test:
  imports:
    - tensorflow
  commands:
    # estimator_ckpt_converter requires tensorflow-estimator
    #- estimator_ckpt_converter --help
    - saved_model_cli --help || echo $?
    - tf_upgrade_v2 --help
    - tflite_convert --help  # [not win]
    - toco_from_protos --help  # [not win]
    - toco --help  # [not win]

about:
  home: https://tensorflow.org/
  license: Apache-2.0
  license_family: Apache
  summary: TensorFlow is a machine learning library, base package contains only tensorflow.
  description: |
    TensorFlow provides multiple APIs.The lowest level API, TensorFlow Core
    provides you with complete programming control.
    Base package contains only tensorflow, not tensorflow-tensorboard.
  dev_url: https://github.com/tensorflow/tensorflow
  doc_url: https://www.tensorflow.org/api_docs
  doc_source_url: https://github.com/tensorflow/docs/

extra:
  tflow_variant: {{ tflow_variant }}
