# 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 = "lalframe" %}

# 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 = "@BASE_VERSION@" %}
{% set nightly_version = "@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 = "@MIN_LAL_VERSION@a0" %}
{% set framel_version = "@MIN_FRAMEL_VERSION@,<9.0.0a0" %}
{% set framecpp_version = "@MIN_FRAMECPPC_VERSION@,<3.0.0a0" %}
{% set swig_version = "@MIN_SWIG_VERSION@" %}

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

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

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

requirements:
  build:
    - {{ compiler('c') }}
    - make
    - pkg-config
    - swig >={{ swig_version }}
  host:
    - ldas-tools-framecpp >={{ framecpp_version }}
    - libframel >={{ framel_version }}
    - liblal >={{ lal_version }}

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

  - name: python-lalframe
    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=@NIGHTLY_VERSION@
        - GITLAB_CI
    requirements:
      build:
        - {{ compiler('c') }}
        - help2man >=1.37  # [build_platform == target_platform]
        - make
        - pkg-config
        - swig >={{ swig_version }}
        # extras for cross compiling with python
        - python                              # [build_platform != target_platform]
        - cross-python_{{ target_platform }}  # [build_platform != target_platform]
        - numpy                               # [build_platform != target_platform]
      host:
        - {{ pin_subpackage('liblalframe', exact=True) }}
        - numpy
        - pytest  # [build_platform == target_platform]
        - python
        - python-lal >={{ lal_version }}
      run:
        - {{ pin_subpackage('liblalframe', exact=True) }}
        - {{ pin_compatible('numpy') }}
        - python
        - python-lal >={{ lal_version }}
    test:
      requires:
        - pytest >=4.0.0a0
      source_files:
        - test/python
        - test/F-TEST-*.gwf
      commands:
        - python -m pytest -ra -v --junit-xml=${CI_PROJECT_DIR:-.}/junit-python${PY_VER}.xml test/python
      imports:
        - lalframe
        - lalframe.frread
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalframe/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Frame Library
      description: |
        The LSC Algorithm Frame Library for gravitational wave data analysis.
        This package contains the python bindings.

  - name: lalframe
    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('liblalframe', exact=True) }}
        - python
      run:
        - liblal >={{ lal_version }}
        - {{ pin_subpackage('liblalframe', exact=True) }}
        - python
        - {{ pin_subpackage('python-lalframe', exact=True) }}
    test:
      source_files:
        - test/F-TEST-600000000-60.gwf
      imports:
        - lalframe
      commands:
        - lalframe_version --verbose
        - lalfr-cksum test/F-TEST-600000000-60.gwf
        - lalfr-cut H1:LSC-AS_Q test/F-TEST-600000000-60.gwf > /dev/null
        - lalfr-dump test/F-TEST-600000000-60.gwf
        - lalfr-paste test/F-TEST-600000000-60.gwf > /dev/null
        - lalfr-split test/F-TEST-600000000-60.gwf
        - lalfr-stat test/F-TEST-600000000-60.gwf
        - lalfr-stream --channel H1:LSC-AS_Q --start-time 600000000 --duration 0.01 --frame-glob test/F-TEST-*.gwf
        - lalfr-vis --channel H1:LSC-AS_Q --start-time 600000000 --duration 0.01 --frame-glob test/F-TEST-*.gwf
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalframe/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Frame Library
      description: |
        The LSC Algorithm Frame Library for gravitational wave data analysis.
        This package contains the runtime tools.

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

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