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

# set version based on nightly
# (we rebuild the nightly version ourselves because the tarball might have
#  been generated on a different day)
{% set base_version = "7.3.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 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') }}
    - pkg-config >=0.18.0
    - make
    - bc
    - swig >={{ swig_version }}
  host:
    - fftw * nompi*  # [fft_impl == "fftw"]
    - gsl
    - hdf5
    - mkl-devel {{ mkl }}  # [fft_impl == "mkl"]
    - zlib

outputs:
  - name: liblal
    script: install-lib.sh
    build:
      run_exports:
        - {{ pin_subpackage("liblal", max_pin="x") }}
      string: {{ fft_impl }}_h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
    requirements:
      build:
        - {{ compiler('c') }}
        - make  # [not win]
        - swig >=3.0.9
      host:
        - fftw * nompi*  # [fft_impl == "fftw"]
        - gsl
        - hdf5
        - mkl-devel {{ mkl }}  # [fft_impl == "mkl"]
        - zlib
      run:
        - fftw  # [fft_impl == "fftw"]
        - gsl
        - hdf5
        - libzlib
      run_constrained:
        # make sure downstream packages are updated beyond the first
        # appearance of liblal
        - lal >=7.1.1
        - python-lal >=7.1.1
    test:
      requires:
        - pkg-config
      commands:
        # check library
        - test -f ${PREFIX}/lib/liblal${SHLIB_EXT}  # [not win]
        - test -f ${PREFIX}/lib/liblalsupport${SHLIB_EXT}  # [not win]
        # check pkg-config
        - pkg-config --print-errors --exact-version "{{ version }}" lal
        - pkg-config --print-errors --exact-version "{{ version }}" lalsupport
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lal/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Library shared object libraries
      description: |
        The LSC Algorithm Library for gravitational wave data analysis.
        This package contains the shared object libraries need to build
        applications that use LAL.

  - name: python-lal
    script: build-python.sh
    build:
      error_overdepending: true
      error_overlinking: true
      ignore_run_exports:
        - libzlib
        - numpy
        - python
        # things we declare to help the solver, but don't actually need
        - mkl
      script_env:
        - CI_COMMIT_TAG
        - CI_PIPELINE_SOURCE
        - ENABLE_NIGHTLY=
        - GITLAB_CI
      string: {{ fft_impl }}_py{{ py }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
    requirements:
      build:
        - {{ compiler('c') }}
        - help2man >=1.37
        - make  # [unix]
        - pkg-config >=0.18.0
        - 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('liblal', exact=True) }}
        - numpy
        - pytest  # [build_platform == target_platform]
        - python
        - six
        - zlib
        # provided to assist the solver, but not actually used
        - mkl-devel {{ mkl }}  # [fft_impl == "mkl"]
      run:
        - {{ pin_subpackage('liblal', exact=True) }}
        - ligo-segments
        - {{ pin_compatible('numpy') }}
        - python
        - python-dateutil
        - scipy
    test:
      requires:
        - freezegun
        - lscsoft-glue
        - pytest >=4.0.0a0
        - python-ligo-lw
      source_files:
        - test/python
      commands:
        - python -m pytest -ra -v --junit-xml=${CI_PROJECT_DIR:-.}/junit-python${PY_VER}.xml test/python
      imports:
        - lal
        - lal.antenna
        - lal.gpstime
        - lal.rate
        - lal.series
        - lal.utils
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lal/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Library Python bindings
      description: |
        The LSC Algorithm Library for gravitational wave data analysis.
        This package contains the Python bindings.

  - name: lal
    script: install-bin.sh
    build:
      error_overdepending: true
      error_overlinking: true
      ignore_run_exports:
        - libzlib
        - numpy
        - python
      string: {{ fft_impl }}_py{{ py }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
    requirements:
      build:
        - {{ compiler('c') }}
        - help2man >=1.37  # [build_platform == target_platform]
        - make  # [unix]
        - sed
      host:
        - fftw  # [fft_impl == "fftw"]
        - {{ pin_subpackage('liblal', exact=True) }}
        - ligo-segments
        - python
        - {{ pin_subpackage('python-lal', exact=True) }}
        - zlib
        # extras to help the solver
        - mkl {{ mkl }}  # [fft_impl == "mkl"]
      run:
        - fftw  # [fft_impl == "fftw"]
        - {{ pin_subpackage('liblal', exact=True) }}
        - ligo-segments
        - numpy
        - python
        - {{ pin_subpackage('python-lal', exact=True) }}
    about:
      home: https://wiki.ligo.org/Computing/LALSuite
      doc_url: https://lscsoft.docs.ligo.org/lalsuite/lal/
      dev_url: https://git.ligo.org/lscsoft/lalsuite/
      license: GPL-2.0-or-later
      license_family: GPL
      license_file: COPYING
      summary: LSC Algorithm Library runtime tools
      description: |
        The LSC Algorithm Library for gravitational wave data analysis.
        This package contains the runtime tools.
    test:
      commands:
        - lal_version --verbose
        - lal_simd_detect
      imports:
        - lal

about:
  home: https://wiki.ligo.org/Computing/LALSuite
  doc_url: https://lscsoft.docs.ligo.org/lalsuite/lal/
  dev_url: https://git.ligo.org/lscsoft/lalsuite/
  license: GPL-2.0-or-later
  license_family: GPL
  license_file: COPYING
  summary: LSC Algorithm Library
  description: |
    The LSC Algorithm Library for gravitational wave data analysis.
    This package contains the shared-object libraries needed to run
    applications that use the LAL library.  If you want to install
    the Python bindings, please install the associated python-lal
    package.

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