File python-PyWavelets.spec of Package python-PyWavelets

#
# spec file for package python-PyWavelets
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%bcond_without tests

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-PyWavelets
Version:        0.5.2
Release:        0
Summary:        PyWavelets is a Python wavelet transforms module
License:        MIT
Group:          Development/Libraries/Python
Url:            http://pypi.python.org/pypi/PyWavelets/
Source0:        https://files.pythonhosted.org/packages/source/P/PyWavelets/PyWavelets-%{version}.tar.gz
# PATCH-FIX-UPSTREAM add_default_to_switch_statement.patch -- Fix no return in nonvoid function error
Patch0:         add_default_to_switch_statement.patch
BuildRequires:  %{python_module Cython}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module numpy-devel >= 1.6.2}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
# Documentation requirements
BuildRequires:  python3-Pygments
BuildRequires:  python3-Sphinx
BuildRequires:  python3-numpydoc
%if %{with tests}
BuildRequires:  %{python_module nose}
%endif
Requires:       python-numpy >= 1.6.2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%python_subpackages

%description
PyWavelets is a Python wavelet transforms module that can do:

  * 1D and 2D Forward and Inverse Discrete Wavelet Transform (DWT and IDWT)
  * 1D and 2D Stationary Wavelet Transform (Undecimated Wavelet Transform)
  * 1D and 2D Wavelet Packet decomposition and reconstruction
  * Computing Approximations of wavelet and scaling functions
  * Over seventy built-in wavelet filters and support for custom wavelets
  * Single and double precision calculations
  * Results compatibility with Matlab Wavelet Toolbox

%package -n %{name}-doc
Summary:        This package contains the HMTL documentation of %{name}
Group:          Documentation/HTML
Provides:       %{python_module PyWavelets-doc = %{version}}

%description -n %{name}-doc
PyWavelets is a Python wavelet transforms module that can do:

  * 1D and 2D Forward and Inverse Discrete Wavelet Transform (DWT and IDWT)
  * 1D and 2D Stationary Wavelet Transform (Undecimated Wavelet Transform)
  * 1D and 2D Wavelet Packet decomposition and reconstruction
  * Computing Approximations of wavelet and scaling functions
  * Over seventy built-in wavelet filters and support for custom wavelets
  * Single and double precision calculations
  * Results compatibility with Matlab Wavelet Toolbox

This Package contains the documentation of %{name} in HTML format.

%prep
%setup -q -n PyWavelets-%{version}
%patch0 -p1

# Make docs non-executable
chmod a-x *.rst
chmod a-x *.txt
chmod a-x PyWavelets.egg-info/*

# Fix wrong-script-interpreter
find demo -name '*.py' -exec sed -i "s|#!/usr/bin/env python|#!%__python3|"  {} \;

# Remove unneeded shebangs
sed -i '1{\@^#!/usr/bin/env python@d}' pywt/data/create_dat.py

# Remove unneeded executable bits
for lib in test_concurrent test_data test_deprecations test_doc test_matlab_compatibility test_matlab_compatibility_cwt test_thresholding data/generate_matlab_data data/generate_matlab_data_cwt ; do
   chmod a-x pywt/tests/$lib.py
done

%build
export CFLAGS="%{optflags} -fno-strict-aliasing"
%python_build

%install
%python_install

%{python_expand pushd %{buildroot}%{$python_sitearch}
# Fix wrong-script-interpreter
sed -i "s|#!/usr/bin/env python|#!%__$python|" pywt/tests/*.py
# Deduplicating files can generate a RPMLINT warning for pyc mtime
$python -m compileall -d %{$python_sitearch} pywt/tests/
$python -O -m compileall -d %{$python_sitearch} pywt/tests/
%fdupes .
popd
}

# Create docs.  These need the package to already be built and installed
PYTHONPATH="$PYTHONPATH:%{buildroot}%{python3_sitearch}" make -C doc PAPER=letter html

# Remove hiden files
find doc/build/html -name '.*' -exec rm {} \;

%if %{with tests}
%check
export CFLAGS="%{optflags} -fno-strict-aliasing"
%python_exec setup.py test
%endif

%files %{python_files}
%defattr(-,root,root)
%doc CHANGES.txt README.rst THANKS.txt
%{python_sitearch}/pywt/
%{python_sitearch}/PyWavelets-%{version}-py*.egg-info

%files -n %{name}-doc
%defattr(-,root,root)
%doc doc/build/html
%doc demo/

%changelog
openSUSE Build Service is sponsored by