{% set name = "OpenMS" %}
{% set version = "2.5.0" %}
package:
  name: {{ name|lower  }}-meta
  version: {{ version  }}

source:
  url: https://github.com/OpenMS/OpenMS/releases/download/Release{{ version }}/OpenMS-{{ version }}-src.tar.gz
  sha256: af62010174f9e04d158fadfd4efdc5c3c9acc2b85a04ab2190ddd97a2f1ad7df
  patches:
    - apple_pyoms_nofixup.patch
    - init.py.patch
    - MANIFEST.in.patch

build:
  number: 2

# Try this when building with GUI
#extra:
#  container:
#    extended-base: True

requirements:
  build:
    - {{ compiler('cxx') }}
    - cmake
    - autoconf
    - automake
  host:
    # openms-general
    - llvm-openmp # [osx]
    - zlib
    - libtool
    - xerces-c
    - boost-cpp
    - eigen
    - glpk
    - hdf5
    - bzip2
    - qt >=5.5
    - libsvm
    - seqan-library ==1.4.2
    - coinmp
    - sqlite

    # Unfortunately we can't include a dependency on the subpackages here
    # (probably bc of the jinja function in the compiler; but we need it
    # since this meta build prepares all the other builds and saves time)
    # Instead, we create an openms-full package later.
    
test:
  commands:
    - conda inspect linkages -p $PREFIX $PKG_NAME  # [not win]
    - conda inspect objects -p $PREFIX $PKG_NAME  # [osx]

outputs:
  - name: libopenms
    version: {{ version }}
    script: package_libopenms.sh
    requirements:
        # build requirements should be loaded from the meta package already.
        # But since the other packages depend on its run_exports
        # We want to make sure that the versions of the dependencies used are the same as above
        build:
          - {{ compiler('cxx') }}
          - cmake
          - autoconf
          - automake
        host:
          # openms-general
          - llvm-openmp # [osx]
          - zlib
          - libtool
          - xerces-c
          - boost-cpp
          - eigen
          - glpk
          - hdf5
          - bzip2
          - qt >=5.5
          - libsvm
          - seqan-library ==1.4.2
          - coinmp
          - sqlite
    build:
      run_exports:
          - {{ pin_compatible('llvm-openmp', max_pin='x.x') }} # [osx]
          - {{ pin_compatible('zlib', max_pin='x.x') }}
          - {{ pin_compatible('xerces-c', max_pin='x.x') }}
          - {{ pin_compatible('boost-cpp', max_pin='x.x') }}
          - {{ pin_compatible('eigen', max_pin='x.x') }}
          - {{ pin_compatible('glpk', max_pin='x.x') }}
          - {{ pin_compatible('hdf5', max_pin='x.x') }}
          - {{ pin_compatible('bzip2', max_pin='x.x') }}
          - {{ pin_compatible('qt', max_pin='x.x') }}
          - {{ pin_compatible('libsvm', max_pin='x.x') }}
          - {{ pin_compatible('coinmp', max_pin='x.x') }}
          - {{ pin_compatible('sqlite', max_pin='x.x') }}
          - libopenms {{ version }}

  - name: openms
    version: {{ version }}
    script: package_openms-tools.sh
    requirements:
      # TODO not sure if build reqs are needed
      build:
        - {{ compiler('cxx') }}
      host:
        - {{ pin_subpackage('libopenms', exact=True) }}
      # conda apparently does not support run_exports in subpackages yet. https://github.com/conda/conda-build/issues/3478
      # so specify everything again, such that EXACTLY the same versions are used! Current problem is boost.
      # In the meta build it uses e.g. 1.72 but the tests for the tools suddenly choose 1.70
      # I could not get the "resolved_packages" jinja function to gather dependencies from other subpackages.
        - llvm-openmp # [osx]
        - zlib
        - libtool
        - xerces-c
        - boost-cpp
        - eigen
        - glpk
        - hdf5
        - bzip2
        - qt >=5.5
        - libsvm
        - seqan-library ==1.4.2
        - coinmp
        - sqlite
      run:
        - {{ pin_subpackage('libopenms', exact=True) }}
        - {{ pin_compatible('llvm-openmp', max_pin='x.x') }} # [osx]
        - {{ pin_compatible('zlib', max_pin='x.x') }}
        - {{ pin_compatible('xerces-c', max_pin='x.x') }}
        - {{ pin_compatible('boost-cpp', max_pin='x.x') }}
        - {{ pin_compatible('eigen', max_pin='x.x') }}
        - {{ pin_compatible('glpk', max_pin='x.x') }}
        - {{ pin_compatible('hdf5', max_pin='x.x') }}
        - {{ pin_compatible('bzip2', max_pin='x.x') }}
        - {{ pin_compatible('qt', max_pin='x.x') }}
        - {{ pin_compatible('libsvm', max_pin='x.x') }}
        - {{ pin_compatible('coinmp', max_pin='x.x') }}
        - {{ pin_compatible('sqlite', max_pin='x.x') }}
    test:
      commands:
        - OPENMS_DATA_PATH=${PREFIX}/share/OpenMS/ ${PREFIX}/bin/FileMerger --help  

  - name: pyopenms
    version: {{ version }}
    script: install_pyopenms.sh
    # problem with pyopenms is: We could in theory skip CMake configuration
    # and save a lot of build dependencies BUT then env.py
    # does not contain the right paths anymore, since the build folder is copied for each
    # subpackage.
    requirements:
      build:
        - {{ compiler('cxx') }}
        - cmake
      host:
        - {{ pin_subpackage('libopenms', exact=True) }}
        - llvm-openmp # [osx]
        - zlib
        - libtool
        - xerces-c
        - boost
        - eigen
        - glpk
        - hdf5
        - bzip2
        - qt >=5.5
        - libsvm
        - seqan-library ==1.4.2
        - coinmp
        - sqlite
        - python {{ python }}
        - cython
        - autowrap
        - numpy
        - pip
        - nose
      run:
        - {{ pin_subpackage('libopenms', exact=True) }}
        - {{ pin_compatible('llvm-openmp', max_pin='x.x') }} # [osx]
        - {{ pin_compatible('zlib', max_pin='x.x') }}
        - {{ pin_compatible('xerces-c', max_pin='x.x') }}
        - {{ pin_compatible('boost', max_pin='x.x') }}
        - {{ pin_compatible('eigen', max_pin='x.x') }}
        - {{ pin_compatible('glpk', max_pin='x.x') }}
        - {{ pin_compatible('hdf5', max_pin='x.x') }}
        - {{ pin_compatible('bzip2', max_pin='x.x') }}
        - {{ pin_compatible('qt', max_pin='x.x') }}
        - {{ pin_compatible('libsvm', max_pin='x.x') }}
        - {{ pin_compatible('coinmp', max_pin='x.x') }}
        - {{ pin_compatible('sqlite', max_pin='x.x') }}
        - python {{ python }}
        - numpy
    test:
      commands:
        - python -c "import pyopenms; print(pyopenms.__version__)"
        # We cant use the PYTHON variable since it does not exist on the biocontainer?!

  - name: openms-thirdparty
    version: {{ version }}
    requirements:
      run:
        - {{ pin_subpackage('openms', exact=True) }}
        - bumbershoot ==3_0_11579
        - comet-ms ==2016013
        - crux-toolkit ==3.2
        - fido ==1.0
        - luciphor2 ==2018_06_28
        - msgf_plus ==2017.07.21
        - omssa ==2.1.9
        - pepnovo ==20101117
        - percolator ==3.4
        - sirius-csifingerid ==4.0.1
        - thermorawfileparser ==1.2.3
        - xtandem ==15.12.15.2
        - gnuplot

about:
  home: https://github.com/OpenMS/OpenMS
  license: BSD
  license_file: LICENSE
  summary: OpenMS is an open-source software C++ library for LC-MS data management and analyses

extra:
  skip-lints:
    - build_number_needs_reset  # our linter has some issues with multi-package recipes as it seems
  identifiers:
    - biotools:openms
    - doi:10.1038/nmeth.3959
