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

# 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 lalmetaio_version = "@MIN_LALMETAIO_VERSION@a0" %}
{% set lalsimulation_version = "@MIN_LALSIMULATION_VERSION@a0" %}
{% set python_ligo_lw_version = "@MIN_PYTHON_LIGO_LW_VERSION@" %}
{% set swig_version = "@MIN_SWIG_VERSION@" %}

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=@NIGHTLY_VERSION@
    - GITLAB_CI
  skip: true  # [win]

requirements:
  build:
    - {{ compiler('c') }}
    - help2man >=1.37  # [build_platform == target_platform]
    - make
    - pkg-config >=0.18.0
    - swig >={{ swig_version }}
  host:
    - gsl
    - liblal >={{ lal_version }}
    - liblalmetaio >={{ lalmetaio_version }}
    - liblalsimulation >={{ lalsimulation_version }}

outputs:
  - name: liblalburst
    script: install-lib.sh
    build:
      run_exports:
        - {{ pin_subpackage("liblalburst", max_pin="x") }}
    requirements:
      build:
        - {{ compiler('c') }}
        - make
        - swig >={{ swig_version }}
      host:
        - gsl
        - liblal >={{ lal_version }}
        - liblalmetaio >={{ lalmetaio_version }}
        - liblalsimulation >={{ lalsimulation_version }}
      run:
        - gsl
        - liblal >={{ lal_version }}
        - liblalmetaio >={{ lalmetaio_version }}
        - liblalsimulation >={{ lalsimulation_version }}
      run_constrained:
        - lalburst >=1.5.7
        - python-lalburst >=1.5.7
    test:
      requires:
        - pkg-config
      commands:
        # check library
        - test -f ${PREFIX}/lib/liblalburst${SHLIB_EXT}  # [unix]
        # check pkg-config
        - pkg-config --print-errors --exact-version "${PKG_VERSION}" lalburst
    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 Burst Library shared object libraries
      description: |
        The LSC Algorithm Burst Library for gravitational wave data analysis.
        This package contains the shared-object libraries needed to run
        applications that use the LAL Burst library.

  - name: python-lalburst
    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 >=0.18.0
        - 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:
        - gsl
        - {{ pin_subpackage('liblalburst', exact=True) }}
        - lscsoft-glue
        - numpy
        - pytest  # [build_platform == target_platform]
        - python
        - python-lal >={{ lal_version }}
        - python-lalmetaio >={{ lalmetaio_version }}
        - python-lalsimulation >={{ lalsimulation_version }}
        - scipy
        - tqdm
      run:
        - gsl
        - {{ pin_subpackage('liblalburst', exact=True) }}
        - ligo-segments
        - lscsoft-glue
        - matplotlib-base
        - {{ pin_compatible('numpy') }}
        - python
        - python-lal >={{ lal_version }}
        - python-lalmetaio >={{ lalmetaio_version }}
        - python-lalsimulation >={{ lalsimulation_version }}
        - python-ligo-lw >={{ python_ligo_lw_version }}
        - scipy
        - tqdm
    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:
        - lalburst
        - lalburst.SimBurstUtils
        - lalburst.SnglBurstUtils
        - lalburst.binjfind
        - lalburst.bucluster
        - lalburst.burca
        - lalburst.burca_tailor
        - lalburst.cafe
        - lalburst.calc_likelihood
        - lalburst.cs_gamma
        - lalburst.date
        - lalburst.packing
        - lalburst.snglcluster
        - lalburst.snglcoinc
        - lalburst.timeslides
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalburst/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Burst Library python python bindings
      description: |
        The LSC Algorithm Burst Library for gravitational wave data analysis.
        This package contains the python bindings.

  - name: lalburst
    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('liblalburst', exact=True) }}
        - python
      run:
        - liblal >={{ lal_version }}
        - {{ pin_subpackage('liblalburst', exact=True) }}
        - python
        - pillow
        - {{ pin_subpackage('python-lalburst', exact=True) }}
    test:
      commands:
        - lalburst_cluster --help
        - lalburst_coinc --help
        - lalburst_cut --help
        - lalburst_gen_timeslides --help
        - lalburst_injfind --help
        - lalburst_inj_pic --help
        - lalburst_plot_tisi --help
        - lalburst_power_calc_likelihood --help
        - lalburst_power_final --help
        - lalburst_power_meas_likelihood --help
        - lalburst_power_plot_binj --help
        - lalburst_power_plot_binjtf --help
        - lalburst_version --verbose
      imports:
        - lalburst
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lalburst/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Burst Library
      description: |
        The LSC Algorithm Burst Library for gravitational wave data analysis.

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

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