File lalinference.spec of Package lalinference

# spec file for package lalinference
# Copyright (c) 2021 SUSE LLC
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define shlib lib%{name}21
# octave >= 6 not supported
%bcond_with octave

# astropy not supported for python < 3.7
%define skip_python2  1
%define skip_python36 1

Name:           lalinference
Version:        2.0.6
Release:        0
Summary:        LSC Algorithm Inference Library
License:        GPL-2.0-or-later
Group:          Productivity/Scientific/Physics
# PATCH-FIX-UPSTREAM lalinference-printf-data-type-consistency.patch -- Cast data passed to printf from size_t to long to make it consistent with the format "%li"; this fixes build failures on i586
Patch0:         lalinference-printf-data-type-consistency.patch
BuildRequires:  %{python_module Shapely}
BuildRequires:  %{python_module astropy}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module glue >= 1.54.1}
BuildRequires:  %{python_module lal >= 7.1.0}
BuildRequires:  %{python_module lalburst >= 1.5.3}
BuildRequires:  %{python_module lalframe >= 1.4.0}
BuildRequires:  %{python_module lalinspiral >= 2.0.0}
BuildRequires:  %{python_module lalmetaio >= 2.0.0}
BuildRequires:  %{python_module lalpulsar >= 3.0.0}
BuildRequires:  %{python_module lalsimulation >= 2.5.0}
BuildRequires:  %{python_module matplotlib >= 1.2.0}
BuildRequires:  %{python_module numpy-devel >= 1.7}
BuildRequires:  %{python_module numpy}
BuildRequires:  %{python_module scipy >= 0.9.0}
BuildRequires:  fdupes
BuildRequires:  pkgconfig
BuildRequires:  python-rpm-macros
BuildRequires:  swig
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(lal)
BuildRequires:  pkgconfig(lalburst)
BuildRequires:  pkgconfig(lalframe)
BuildRequires:  pkgconfig(lalinspiral)
BuildRequires:  pkgconfig(lalmetaio)
BuildRequires:  pkgconfig(lalpulsar)
BuildRequires:  pkgconfig(lalsimulation)
BuildRequires:  pkgconfig(libmetaio)
# SECTION For tests (python3 only)
BuildRequires:  %{python_module h5py}
BuildRequires:  %{python_module healpy >= 1.9.1}
BuildRequires:  %{python_module pytest}
%if %{with octave}
BuildRequires:  octave-lal
BuildRequires:  octave-lalburst
BuildRequires:  octave-lalframe
BuildRequires:  octave-lalinspiral
BuildRequires:  octave-lalmetaio
BuildRequires:  octave-lalpulsar
BuildRequires:  octave-lalsimulation
BuildRequires:  pkgconfig(octave)
Requires:       %{name}-data = %{version}
Requires:       python-lal
Requires:       python-lalframe
Requires:       python-lalinspiral
Requires:       python-lalmetaio
Requires:       python-lalpulsar
Requires:       python-lalsimulation


The LSC Algorithm Inference Library for gravitational wave data analysis.

%package -n %{shlib}
Summary:        Shared library for LAL Inference
Group:          Productivity/Scientific/Physics

%description -n %{shlib}
This package contains the shared-object libraries needed to run applications
that use the LAL Inference library.

%package -n %{name}-devel
Summary:        Development files for LAL Inference
Group:          Development/Libraries/C and C++
Requires:       %{name}-data = %{version}
Requires:       %{shlib} = %{version}
Requires:       pkgconfig(gsl)
Requires:       pkgconfig(lal)
Requires:       pkgconfig(lalburst)
Requires:       pkgconfig(lalframe)
Requires:       pkgconfig(lalinspiral)
Requires:       pkgconfig(lalmetaio)
Requires:       pkgconfig(lalpulsar)
Requires:       pkgconfig(lalsimulation)
Requires:       pkgconfig(libmetaio)

%description -n %{name}-devel
This package contains sources and header files needed to build applications
that use the LAL Inference library.

%package -n %{name}-data
Summary:        Data files for lalinference
Group:          Productivity/Scientific/Physics
Provides:       %{python_module lalinference-data}

%description -n %{name}-data
This package provides the data files for lalinference.

%package -n octave-lalinference
Summary:        Octave bindings for LAL Inference
Group:          Productivity/Scientific/Physics
Requires:       %{name}-data = %{version}
Requires:       octave-lal
Requires:       octave-lalburst
Requires:       octave-lalframe
Requires:       octave-lalinspiral
Requires:       octave-lalmetaio
Requires:       octave-lalpulsar
Requires:       octave-lalsimulation
%requires_eq    octave-cli

%description -n octave-lalinference
This package provides the necessary files for using LAL Inference with octave.

%autosetup -p1

%{python_expand # Necessary to run %%configure with all python flavors
export PYTHON=%{_bindir}/$python
mkdir ../$python
cp -pr ./ ../$python  
pushd ../$python
%configure \
  %{?with_octave:--enable-swig-octave} \
make %{?_smp_mflags}

%{python_expand # install for all python flavors
export PYTHON=%{_bindir}/$python
pushd ../$python

# We do not use upstream's env files because they also set more generic
# variables (e.g. PATH) which may ruin setups

rm %{buildroot}%{_sysconfdir}/%{name}-user-env.*

cat << EOF >> %{name}.sh
export LALINFERENCE_PREFIX=%{_prefix}
export LALINFERENCE_DATADIR=%{_datadir}/%{name}

cat << EOF >> %{name}.csh
setenv LALINFERENCE_PREFIX "%{_prefix}"
setenv LALINFERENCE_DATADIR "%{_datadir}/%{name}"

cat << EOF >> %{name}.fish
set LALINFERENCE_PREFIX (echo "%{_prefix}" | %{_bindir}/sed -e 's| |:|g;')
set LALINFERENCE_DATADIR (echo "%{_datadir}/%{name}" | %{_bindir}/sed -e 's| |:|g;')

install -D -m0644 %{name}.sh %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
install -D -m0644 %{name}.csh %{buildroot}%{_sysconfdir}/profile.d/%{name}.csh
install -D -m0644 %{name}.fish %{buildroot}%{_sysconfdir}/profile.d/%{name}.fish


find %{buildroot}%{_libdir}/ -name "*.a" -delete -print
find %{buildroot} -type f -name "*.la" -delete -print

%{python_expand # FIX env HASHBANGS
sed -Ei "1{/^#!\/usr\/bin\/env python/d}" %{buildroot}%{$python_sitearch}/lalinference/tiger/
sed -Ei "1{/^#!\/usr\/bin\/env python/d}" %{buildroot}%{$python_sitearch}/lalinference/tiger/
sed -Ei "1{/^#!\/usr\/bin\/env python/d}" %{buildroot}%{$python_sitearch}/lalinference/tiger/

sed -E -i "1 s|^#\!\s*%{_bindir}/env\s*bash|#\!/bin/bash|" %{buildroot}%{_bindir}/lalinference_mpi_wrapper

%python_expand %fdupes %{buildroot}%{$python_sitearch}/%{name}/

%{python_expand # check for all python flavors
export PYTHON=%{_bindir}/$python
pushd ../$python
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
%make_build check

%post -n %{shlib} -p /sbin/ldconfig
%postun -n %{shlib} -p /sbin/ldconfig

%files -n %{shlib}

%files -n %{name}-devel
%license COPYING
%config %{_sysconfdir}/profile.d/%{name}.*

%if %{with octave}
%files -n octave-%{name}
%dir %{_libdir}/octave/*/site
%dir %{_libdir}/octave/*/site/oct
%dir %{_libdir}/octave/*/site/oct/*

%files %{python_files}
%if "%{python_flavor}" == "python3" || "%{python_provides}" == "python3"

%files -n %{name}-data

openSUSE Build Service is sponsored by