Blob Blame History Raw
# Created by pyp2rpm-3.3.2
%global pypi_name h2
%global JQUERY_VERSION %(rpm -q js-jquery --queryformat '%%{version}')
%global SPHINX_JQUERY_VERSION 3.5.1
%global SPHINX_UNDERSCORE_VERSION 1.13.1


%global common_description %{expand:
HTTP/2 Protocol Stack This repository contains a pure-Python
implementation of a HTTP/2 protocol stack. It's written from the ground up to
be embeddable in whatever program you choose to use, ensuring that you can
speak HTTP/2 regardless of your programming paradigm.}

%bcond_without docs

Name:           python-%{pypi_name}
Version:        4.1.0
Release:        %autorelease
Summary:        HTTP/2 State-Machine based protocol implementation

License:        MIT
URL:            https://hyper-h2.readthedocs.io
Source0:        %pypi_source

BuildArch:      noarch

BuildRequires:  python3-devel

%description
%{common_description}

%package -n     python3-%{pypi_name}
Summary:        %{summary}

%description -n python3-%{pypi_name}
%{common_description}

%if %{with docs}
%package doc
Summary:        Documentation for %{name}

Requires: js-jquery
Requires: js-underscore

%description doc
%{common_description}

This is the documentation package for h2.
%endif

%prep
%autosetup -p1 -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
# Relax pytest-cov dependency
sed -i "s|pytest-cov>=2.10.1,<3|pytest-cov>=2.10.1,<4|" tox.ini

%generate_buildrequires
%pyproject_buildrequires -t -e docs

%if %{with docs}
# Unbundle
echo 'js-jquery'
echo 'js-underscore'
echo 'make'
%endif

%build
%pyproject_wheel

%if %{with docs}
# generate html docs
PYTHONPATH=%{buildroot}%{python3_sitelib} sphinx-build-3 docs/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%pyproject_install

# Unbundle JS
rm -v html/_static/underscore.js
ln -s %{datadir}/javascript/underscore/underscore-min.js html/_static/underscore.js
rm -v html/_static/underscore-%{SPHINX_UNDERSCORE_VERSION}.js
ln -s %{datadir}/javascript/underscore/underscore.js html/_static/underscore-%{SPHINX_UNDERSCORE_VERSION}.js
rm -v html/_static/jquery.js
ln -s %{datadir}/javascript/jquery/%{JQUERY_VERSION}/jquery.min.js html/_static/jquery.js
rm -v html/_static/jquery-%{SPHINX_JQUERY_VERSION}.js
ln -s %{datadir}javascript/jquery/%{JQUERY_VERSION}/jquery.js html/_static/jquery-%{SPHINX_JQUERY_VERSION}.js
%endif

%pyproject_save_files %{pypi_name}

%check
%tox

%files -n python3-%{pypi_name} -f %{pyproject_files}
%license LICENSE
%doc README.rst

%if %{with docs}
%files doc
%doc html
%license LICENSE
%endif

%changelog
%autochangelog