File python-sphinx-rtd-theme.spec of Package python-sphinx-rtd-theme

%define realname sphinx_rtd_theme
%define srcext   tar.xz

# Python 3.x
%if 0%{?rhel} == 8
%define python3_pkg python3
%define python3     %{_libexecdir}/platform-python
%else
%define python3_pkg python3
%define python3     %{_bindir}/python3
%endif

%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)

%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif

# Common info
Name:          %{python3_pkg}-%{realname}
Version:       1.0.0
Release:       0%{?extraver:0.}1
License:       MIT
Group:         Development/Tools/Doc Generators
URL:           https://github.com/snide/sphinx_rtd_theme/
Summary:       Read the Docs Sphinx Theme

# Install-time parameters
Provides:      python3-sphinx-rtd-theme = %{version}-%{release}
Requires:      python(abi) = %{py3_ver}

# Build-time parameters
%if ! 0%{?sles_version}
BuildArch:     noarch
%endif
BuildRequires: %{python3_pkg}-setuptools
BuildRequires: npm
Source:        %{realname}-%{version}%{?extraver}.%{srcext}
# cd sphinx_rtd_theme; npm install --no-save --only=prod && tar -jcf ../node_modules.tar.bz2 node_modules; rm -rf node_modules; cd ..
Source11:      node_modules.tar.bz2

%description
This Sphinx theme was designed to provide a great reader experience for
documentation users on both desktop and mobile devices. This theme is used
primarily on Read the Docs but can work with any Sphinx project. You can find
a working demo of the theme in the theme documentation.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a11
%{__sed} -ri "/npm.+install/ s/\]/, '--only=prod']/" setup.py

%build
%python3 setup.py build

%install
%python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2

%files
%defattr(-,root,root)
%doc LICENSE README.rst
%{python3_sitelib}/*

%changelog
openSUSE Build Service is sponsored by