## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 11;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# RPATH issues are standard paths and result from upstream
%global __brp_check_rpaths %{nil}

Name:          cantera
Version:       3.0.0
Release:       %{?autorelease}
Summary:       Chemical kinetics, thermodynamics, and transport tool suite
License:       BSD
URL:           https://github.com/Cantera/%{name}/
Source0:       %{url}archive/refs/tags/v%{version}.tar.gz

# Python 3.12 currently in pre-release and not officially supported
Patch0:        add-python3_13.patch

BuildRequires:  boost-devel
BuildRequires:  eigen3-devel
BuildRequires:  fmt-devel
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  git
BuildRequires:  hdf5-devel
BuildRequires:  highfive-devel
BuildRequires:  python3
BuildRequires:  python3-devel
BuildRequires:  python3-numpy
BuildRequires:  python3-pip
BuildRequires:  python3-pytest
BuildRequires:  python3-scipy
BuildRequires:  python3-setuptools
BuildRequires:  python3-wheel
BuildRequires:  sundials-devel
BuildRequires:  yaml-cpp-devel


%if 0%{?suse_version}
BuildRequires:  gmock
BuildRequires:  gtest
BuildRequires:  scons
BuildRequires:  python3-Cython
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-Pint
BuildRequires:  python3-ruamel.yaml
%else
BuildRequires:  gmock-devel
BuildRequires:  gtest-devel
BuildRequires:  python3-cython
BuildRequires:  python3-pint
BuildRequires:  python3-scons
BuildRequires:  python3-ruamel-yaml
%endif

%if 0%{?fedora} || 0%{?suse_version}
BuildRequires:  gcc-fortran
BuildRequires:  python3-pandas
%else
BuildRequires:  gcc-gfortran
%endif

%global scons scons%{?rhel:-3}

ExcludeArch: %{ix86}

%global common_description %{expand: \
 Cantera is a suite of object-oriented software tools for solving problems
 involving chemical kinetics, thermodynamics, and/or transport processes.
 Cantera can be used for simulating time-dependent or steady reactor
 networks and one-dimensional reacting flows. Thermodynamic models for
 ideal gases, aqueous electrolytes, plasmas, and multiphase substances
 are provided.}

%description
%{common_description}


%package common
Summary: Common files needed for all Cantera interfaces
%description common
%{common_description}
 .
 This package includes programs for parsing and converting chemical
 mechanisms, a set of common mechanism files, and several sample problems.


%package -n python3-%{name}
Requires: %{name}-common%{_isa} = %{version}-%{release}
Recommends: python3-pint
Summary: Python 3 user interface for Cantera
%description -n python3-%{name}
%{common_description}
 .
 This package includes the Cantera Python 3 module.


%package devel
Requires: %{name}-common%{_isa} = %{version}-%{release}
Summary: Header files and shared object libraries for Cantera
%description devel
%{common_description}
 .
 This package contains the header files and shared object libraries needed to
 develop applications with the C++ and Fortran interfaces of Cantera.


%package static
Requires: %{name}-common%{_isa} = %{version}-%{release}
Summary: Static libraries for Cantera
%description static
%{common_description}
 .
 This package contains the static libraries for the C++ and Fortran
 interfaces of Cantera.


%prep
%autosetup -n %{name}-%{version} -p1

%build
%set_build_flags

%scons build \
    extra_inc_dirs=%{_includedir}/eigen3:%{_includedir}/highfive \
    f90_interface=y \
    hdf_support=y \
    libdirname=%{_lib} \
    prefix=%{_prefix} \
    python_package=full \
    python_prefix=%{_prefix} \
    renamed_shared_libraries=n \
    system_eigen=y \
    system_fmt=y \
    system_highfive=y \
    system_sundials=y \
    system_yamlcpp=y \
    system_blas_lapack=y \
    %{?_smp_mflags}


%install
%scons install \
    libdirname=%{_lib} \
    prefix=%{_prefix} \
    python_prefix=%{_prefix} \
    stage_dir=%{buildroot} \
    %{nil}

%check
%scons test %{?_smp_mflags}


%files common
%license %{_datadir}/%{name}/doc/LICENSE.txt

%doc AUTHORS README.rst
%doc %{_mandir}/man1/ck2yaml.1.gz
%doc %{_mandir}/man1/cti2yaml.1.gz
%doc %{_mandir}/man1/ctml2yaml.1.gz
%doc %{_mandir}/man1/yaml2ck.1.gz

%{_bindir}/ck2yaml
%{_bindir}/cti2yaml
%{_bindir}/ctml2yaml
%{_bindir}/yaml2ck

%{_datadir}/%{name}

#not required for packaged installations
%ghost %{_bindir}/setup_cantera
%ghost %{_bindir}/setup_cantera.csh


%files -n python3-%{name}
%{python3_sitearch}/%{name}/
%{python3_sitearch}/Cantera-%{version}.dist-info/

%files devel
%{_includedir}/%{name}

%{_libdir}/pkgconfig/cantera.pc
%{_libdir}/libcantera.so
%{_libdir}/libcantera.so.3
%{_libdir}/libcantera.so.%{version}
%{_libdir}/libcantera_fortran.so
%{_libdir}/libcantera_fortran.so.3
%{_libdir}/libcantera_fortran.so.%{version}
%{_libdir}/libcantera_python*.so


%files static
%{_libdir}/libcantera.a
%{_libdir}/libcantera_fortran.a


%changelog
## START: Generated by rpmautospec
* Sun Jun 23 2024 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-11
- add python3-pint recommends for Cantera with units

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 3.0.0-10
- Rebuilt for Python 3.13

* Fri Mar 01 2024 Antonio Trande <sagitter@fedoraproject.org> - 3.0.0-9
- Rebuild for sundials-6.7.0

* Sat Feb 17 2024 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-8
- close rbz#2264231, FTBFS: python 3.13 added to supported versions

* Tue Jan 23 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 12 2024 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-5
- fix FTBFS due to distutils removal in Python 3.12 by adding
  BuildRequires: python3-setuptools

* Mon Oct 16 2023 Antonio Trande <sagitter@fedoraproject.org> - 3.0.0-4
- Rebuild for sundials-6.6.1

* Fri Sep 22 2023 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-3
- build with hdf5 support, close rhbz#2236697

* Mon Aug 28 2023 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-2
- drop old patch from repo, tidy up spec and add suse wip

* Fri Aug 25 2023 Mark E. Fuller <mark.e.fuller@gmx.de> - 3.0.0-1
- update to v3.0.0

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-42
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sat Jul 01 2023 Python Maint <python-maint@redhat.com> - 2.6.0-41
- Rebuilt for Python 3.12

* Wed Jun 28 2023 Vitaly Zaitsev <vitaly@easycoding.org> - 2.6.0-40
- Rebuilt due to fmt 10 update.

* Wed Jun 14 2023 Python Maint <python-maint@redhat.com> - 2.6.0-39
- Rebuilt for Python 3.12

* Tue Jan 31 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.6.0-38
- Break long scons invocation lines for readability
- Alphabetize command-line options

* Tue Jan 31 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.6.0-37
- Build and test with parallelism enabled (-j)

* Thu Jan 26 2023 Mark E. Fuller <mark.e.fuller@gmx.de> - 2.6.0-36
- drop x86

* Thu Jan 26 2023 Mark E. Fuller <mark.e.fuller@gmx.de> - 2.6.0-35
- bump c++ std to 14 from 11, close rhbz#2164818

* Wed Jan 18 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Tue Nov 15 2022 Mamoru TASAKA <mtasaka@fedoraproject.org> - 2.6.0-33
- Rebuild for new libyaml-cpp

* Tue Nov 15 2022 Mamoru TASAKA <mtasaka@fedoraproject.org> - 2.6.0-32
- Enable s390x again (after merging F36 branch)

* Thu Oct 20 2022 Mark E. Fuller <mark.e.fuller@gmx.de> - 2.6.0-31
- RPMAUTOSPEC: unresolvable merge
## END: Generated by rpmautospec