# This is a copy of the upstream conda recipe for this package
# hosted at github.com/conda-forge/lal-feedstock and licensed
# under the terms of the BSD 3-Clause license.
# This is only for CI purposes, and should not be considered
# production-ready at any time.

{% set name = "lalmetaio" %}

# set version based on nightly
# (we rebuild the nightly version ourselves because the tarball might have
#  been generate on a different day)
{% set base_version = "4.0.1.1" %}
{% set nightly_version = "" %}
{% if nightly_version %}
{% set version = base_version + "-dev" + datetime.datetime.utcnow().strftime("%Y%m%d") %}
{% else %}
{% set version = base_version %}
{% endif %}

# dependencies
{% set lal_version = "7.3.0a0" %}
{% set metaio_version = "8.4.0" %}
{% set swig_version = "3.0.11" %}

package:
  name: {{ name }}-split
  version: {{ version|replace('-', '.') }}

source:
  url: file://@TARBALL@
  sha256: @SHA256@

build:
  error_overdepending: true
  error_overlinking: true
  number: 9999
  script_env:
    - CI_COMMIT_TAG
    - CI_PIPELINE_SOURCE
    - ENABLE_NIGHTLY=
    - GITLAB_CI
  skip: true  # [win]

requirements:
  build:
    - {{ compiler('c') }}
    - make
    - pkg-config >=0.18.0
    - swig >={{ swig_version }}
  host:
    - liblal >={{ lal_version }}
    - libmetaio >={{ metaio_version }}

outputs:
  - name: liblalmetaio
    script: install-lib.sh
    build:
      error_overdepending: true
      error_overlinking: true
      run_exports:
        - {{ pin_subpackage("liblalmetaio", max_pin="x") }}
    requirements:
      build:
        - {{ compiler('c') }}
        - make
        - swig >={{ swig_version }}
      host:
        - liblal >={{ lal_version }}
        - libmetaio >={{ metaio_version }}
      run:
        - liblal >={{ lal_version }}
        - libmetaio >={{ metaio_version }}
      run_constrained:
        - lalmetaio >=2.0.1
        - python-lalmetaio >=2.0.1
    test:
      requires:
        - pkg-config
      commands:
        # check library
        - test -f ${PREFIX}/lib/liblalmetaio${SHLIB_EXT}  # [unix]
        # check pkg-config
        - pkg-config --print-errors --exact-version "${PKG_VERSION}" lalmetaio
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalmetaio/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm MetaIO Library
      description: |
        The LSC Algorithm MetaIO Library for gravitational wave data analysis.
        This package contains the shared-object libraries needed to run
        applications that use the LAL MetaIO library.

  - name: python-lalmetaio
    script: build-python.sh
    build:
      error_overdepending: true
      error_overlinking: true
      ignore_run_exports:
        - numpy
        - python
      script_env:
        - CI_COMMIT_TAG
        - CI_PIPELINE_SOURCE
        - ENABLE_NIGHTLY=
        - GITLAB_CI
    requirements:
      build:
        - {{ compiler('c') }}
        - help2man >=1.37  # [build_platform == target_platform]
        - make
        - pkg-config
        - swig >={{ swig_version }}
        # extras for cross-compilation:
        - cross-python_{{ target_platform }}  # [build_platform != target_platform]
        - numpy                               # [build_platform != target_platform]
        - python                              # [build_platform != target_platform]
      host:
        - {{ pin_subpackage('liblalmetaio', exact=True) }}
        - numpy
        - pytest  # [build_platform == target_platform]
        - python
        - python-lal >={{ lal_version }}
      run:
        - {{ pin_subpackage('liblalmetaio', exact=True) }}
        - {{ pin_compatible('numpy') }}
        - python
        - python-lal >={{ lal_version }}
    test:
      requires:
        - pytest >=4.0.0a0
      source_files:
        - test/python
      commands:
        - python -m pytest -ra -v --junit-xml=${CI_PROJECT_DIR:-.}/junit-python${PY_VER}.xml test/python
      imports:
        - lalmetaio
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalmetaio/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm MetaIO Library
      description: |
        The LSC Algorithm MetaIO Library for gravitational wave data analysis.
        This package contains the python bindings.

  - name: lalmetaio
    script: install-bin.sh
    build:
      error_overdepending: true
      error_overlinking: true
      ignore_run_exports:
        - python
    requirements:
      build:
        - {{ compiler('c') }}
        - help2man >=1.37  # [build_platform == target_platform]
        - make
      host:
        - liblal >={{ lal_version }}
        - {{ pin_subpackage('liblalmetaio', exact=True) }}
        - python
      run:
        - liblal >={{ lal_version }}
        - {{ pin_subpackage('liblalmetaio', exact=True) }}
        - python
        - {{ pin_subpackage('python-lalmetaio', exact=True) }}
    test:
      commands:
        - lalmetaio_version --verbose
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalmetaio/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm MetaIO Library
      description: |
        The LSC Algorithm MetaIO Library for gravitational wave data analysis.

about:
  home: https://wiki.ligo.org/Computing/LALSuite
  doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalmetaio/
  dev_url: https://git.ligo.org/lscsoft/lalsuite/
  license: GPL-2.0-or-later
  license_family: GPL
  license_file: COPYING
  summary: LSC Algorithm MetaIO Library
  description: |
    The LSC Algorithm MetaIO Library for gravitational wave data analysis.

extra:
  feedstock-name: lalmetaio
  recipe-maintainers:
    - duncanmmacleod
    - skymoo
