File python-jupyter_core-doc.spec of Package python-jupyter_core

#
# spec file for package python-jupyter_core-doc
#
# Copyright (c) 2018 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/
#


%if 0%{?suse_version} && 0%{?suse_version} > 1320
%bcond_without pdf
%else
%bcond_with pdf
%endif

%bcond_without html

%bcond_without tests

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-jupyter_core-doc
Version:        4.4.0
Release:        0
Summary:        Documentation for python-jupyter_core
License:        BSD-3-Clause
Group:          Development/Languages/Python
Url:            https://github.com/jupyter/jupyter_core
Source:         https://files.pythonhosted.org/packages/source/j/jupyter_core/jupyter_core-%{version}.tar.gz
# PATCH-FIX-OPENSUSE -- use_rpms_paths.patch -- change paths so they are easy to replace at build time
Patch0:         use_rpms_paths.patch
BuildRequires:  %{python_module jupyter_core}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
%if %{with tests}
# Test requirements
BuildRequires:  %{python_module pytest}
# Python 2.7 test requirements
BuildRequires:  python-mock
%endif
# Documentation requirements
BuildRequires:  %{python_module sphinxcontrib-github-alt}
%if %{with pdf} || %{with html}
BuildRequires:  python3-Sphinx
%endif
%if %{with pdf}
BuildRequires:  python3-Sphinx-latex
%endif
Provides:       %{name}-html = %{version}
Provides:       %{name}-pdf = %{version}
Obsoletes:      %{name}-html < %{version}
Obsoletes:      %{name}-pdf < %{version}
Provides:       %{python_module jupyter_core-doc = %{version}}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
Documentation and help files for python-jupyter_core.

%prep
%setup -q -n jupyter_core-%{version}
%patch0 -p1
# Set the appropriate paths dynamically
sed -i "s|\"/usr/share/jupyter\"|\"%{_datadir}/jupyter\"|" jupyter_core/paths.py
sed -i "s|\"/etc/jupyter\"|\"%{_sysconfdir}/jupyter\"|" jupyter_core/paths.py
sed -i "s|(sys\.prefix, 'share', 'jupyter')|('%{_datadir}', 'jupyter')|" jupyter_core/paths.py
sed -i "s|(sys\.prefix, 'etc', 'jupyter')|('%{_sysconfdir}', 'jupyter')|" jupyter_core/paths.py

%build
# Build the documentation
pushd docs
%if %{with html}
make html
rm -rf build/html/.buildinfo
%endif
%if %{with pdf}
make latexpdf
%endif
popd

%install
mkdir -p %{buildroot}%{_docdir}/python-jupyter_core

%if %{with pdf}
cp docs/_build/latex/*.pdf %{buildroot}%{_docdir}/python-jupyter_core/
%endif

%if %{with html}
cp -r docs/_build/html %{buildroot}%{_docdir}/python-jupyter_core/
%endif

cp -r examples %{buildroot}%{_docdir}/python-jupyter_core/
%fdupes %{buildroot}%{_docdir}/python-jupyter_core/

%if %{with tests}
%check
# test_migrate requires files not found in the package
pushd jupyter_core/tests
rm test_migrate.py
%python_expand py.test-%{$python_bin_suffix}
popd
%endif

%files
%defattr(-,root,root,-)
%doc COPYING.md
%{_docdir}/python-jupyter_core/

%changelog
openSUSE Build Service is sponsored by