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

# 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.2.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 lalframe_version = "3.0.0a0" %}
{% set lalmetaio_version = "4.0.0a0" %}
{% set lalsimulation_version = "5.2.0a0" %}
{% set lalburst_version = "2.0.0a0" %}
{% 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
    - swig >={{ swig_version }}
  host:
    - gsl
    - liblal >={{ lal_version }}
    - liblalframe >={{ lalframe_version }}
    - liblalburst >={{ lalburst_version }}
    - liblalmetaio >={{ lalmetaio_version }}
    - liblalsimulation >={{ lalsimulation_version }}

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

  - name: python-lalinspiral
    script: build-python.sh
    build:
      error_overdepending: true
      error_overlinking: true
      ignore_run_exports:
        # liblalburst is required because python-lalburst is used
        - liblalburst
        - 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:
        - liblalburst >={{ lalburst_version }}
        - {{ pin_subpackage('liblalinspiral', exact=True) }}
        - numpy
        - pytest  # [build_platform == target_platform]
        - python
        - python-lal >={{ lal_version }}
        - python-lalburst >={{ lalburst_version }}
        - python-lalframe >={{ lalframe_version }}
        - python-lalmetaio >={{ lalmetaio_version }}
        - python-lalsimulation >={{ lalsimulation_version }}
      run:
        - {{ pin_subpackage('liblalinspiral', exact=True) }}
        - lscsoft-glue
        - {{ pin_compatible('numpy') }}
        - python
        - python-lal >={{ lal_version }}
        - python-lalburst >={{ lalburst_version }}
        - python-lalframe >={{ lalframe_version }}
        - python-lalmetaio >={{ lalmetaio_version }}
        - python-lalsimulation >={{ lalsimulation_version }}
        - python-ligo-lw
        - 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:
        - lalinspiral
        - lalinspiral.inspinjfind
        - lalinspiral.sbank
        - lalinspiral.thinca
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://docs.ligo.org/lscsoft/lalsuite/lalinspiral/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Inspiral Library
      description: |
        The LSC Algorithm Inspiral Library for gravitational wave data analysis.
        This package contains the python bindings.

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

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

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