File python-kwant.spec of Package python-kwant

#
# spec file
#
# Copyright (c) 2022 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 https://bugs.opensuse.org/
#


%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif

# PACKAGE DOES NOT SUPPORT PYTHON2
%define skip_python2 1
%define skip_python38 1

%define modname kwant

Name:           python-kwant%{psuffix}
Version:        1.4.3
Release:        0
Summary:        Python library for numerical quantum transport calculations
License:        BSD-2-Clause
Group:          Development/Languages/Python
URL:            https://kwant-project.org/
Source0:        https://files.pythonhosted.org/packages/source/k/kwant/kwant-%{version}.tar.gz
BuildRequires:  %{python_module Cython}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module numpy-devel}
BuildRequires:  %{python_module scipy}
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module sympy}
BuildRequires:  %{python_module tinyarray}
BuildRequires:  blas-devel
BuildRequires:  fdupes
BuildRequires:  lapack-devel
BuildRequires:  mumps-devel
BuildRequires:  python-rpm-macros
Requires:       python-numpy
Requires:       python-numpy-devel
Requires:       python-scipy
Requires:       python-sympy
Requires:       python-tinyarray
Recommends:     python-matplotlib
Recommends:     python-qsymm
Recommends:     python-sympy
# SECTION test requirements
%if %{with test}
BuildRequires:  %{python_module kwant}
BuildRequires:  %{python_module pytest}
%endif
# /SECTION
# mumps exclusion list is "i586 s390 ppc armv7l" (sic!)
ExcludeArch:    %ix86 %arm

%python_subpackages

%description
Kwant is a Python library for numerical calculations on tight-binding
models with a strong focus on quantum transport. Kwant can be used to
simulate a variety of systems and phenomena in quantum physics
including: metals, graphene, topological insulators, quantum Hall
effect, superconductivity, spintronics, molecular electronics, any
combination of the above, and many other things. Kwant can calculate
transport properties (conductance, noise, scattering matrix),
dispersion relations, modes, wave functions, various Green’s
functions, out-of-equilibrium local quantities.

%prep
%setup -q -n kwant-%{version}

rm kwant/_system.c kwant/operator.c kwant/graph/core.c kwant/linalg/_mumps.c

%build
%if !%{with test}
# CAN'T FIND mumps HEADERS
export CFLAGS="%{optflags} -I%{_includedir}/mumps"
%python_build --cython
%endif

%install
%if !%{with test}
%python_install

# REMOVE UNNEEDED HEADER FILE
#%%python_expand rm %%{buildroot}%%{$python_sitearch}/%%{modname}/graph/defs.h

%python_expand %fdupes %{buildroot}%{$python_sitearch}
%endif

%if %{with test}
%check
# TESTS CANNOT BE RUN FROM TOPLEVEL SOURCE DIR
export PYTHONPATH=%{python_sitearch}
export PYTHONDONTWRITEBYTECODE=1
%python_exec -c 'import kwant; kwant.test()'

%endif

%if !%{with test}
%files %{python_files}
%doc AUTHORS.rst README.rst
%license LICENSE.rst
%{python_sitearch}/%{modname}/
%{python_sitearch}/%{modname}-%{version}-py%{python_version}.egg-info/
%endif

%changelog
openSUSE Build Service is sponsored by