File python-hyper.spec of Package python-hyper

#
# spec file for package python-hyper
#
# Copyright (c) 2021 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/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without python2
%bcond_without python36
Name:           python-hyper
Version:        0.7.0+git88.18b629b
Release:        0
Summary:        HTTP/2 Client for Python
License:        MIT
Group:          Development/Languages/Python
URL:            https://github.com/Lukasa/hyper
Source0:        hyper-%{version}.tar.xz
Patch0:         fix-dependencies.patch
Patch1:         fix-test.patch
Patch2:         pr-402-h2-settings-fix.patch
Patch3:         tests-mark-rpmfail_getaddrinfo.patch
Patch4:         fix-j1-tests.patch
Patch5:         http20.patch
BuildRequires:  %{python_module brotlipy >= 0.7.0}
BuildRequires:  %{python_module h2 > 2.5.0}
BuildRequires:  %{python_module hyperframe >= 3.2}
BuildRequires:  %{python_module mock}
BuildRequires:  %{python_module packaging}
BuildRequires:  %{python_module pytest >= 3.0}
BuildRequires:  %{python_module requests}
BuildRequires:  %{python_module rfc3986 >= 1.1.0}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  openssl(cli)
BuildRequires:  python-rpm-macros
Requires:       python-brotlipy >= 0.7.0
Requires:       python-h2 > 2.5.0
Requires:       python-hyperframe >= 3.2
Requires:       python-rfc3986 >= 1.1.0
Requires(post): update-alternatives
Requires(postun):update-alternatives
%if %{with python2}
BuildRequires:  python-enum34 >= 1.0.4
BuildRequires:  python-futures
%endif
%ifpython2
Requires:       python-enum34
%endif
%python_subpackages

%description
hyper supports the final draft of the HTTP/2 specification: additionally,
it provides support for drafts 14, 15, and 16 of the HTTP/2 specification.
It also supports the final draft of the HPACK specification.

hyper is intended to be a drop-in replacement for http.client, with a
similar API. However, hyper intentionally does not name its classes the
same way http.client does. This is because most servers do not support
HTTP/2 at this time: I don't want you accidentally using hyper when you
wanted http.client.

%prep
%setup -q -n hyper-%{version}
%autopatch -p1

%build
%python_build

%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/hyper
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
# Regenerate test certificates to avoid SSLError EE_KEY_TOO_SMALL
openssl req -x509 -newkey rsa:4096 -keyout test/certs/server.key -out test/certs/server.crt -days 365 -nodes -batch
openssl req -x509 -newkey rsa:4096 -keyout test/certs/client.key -out test/certs/client.crt -days 365 -nodes -batch
openssl req -x509 -newkey rsa:4096 -keyout test/certs/nopassword.pem -out test/certs/nopassword.pem -days 365 -nodes -batch
# test_HTTPConnection_with_custom_context - TLS 1.3 does not support h2
# test_useful_error_with_no_protocol test_goaway_frame_PROTOCOL_ERROR test_goaway_frame_HTTP_1_1_REQUIRED test_goaway_frame_invalid_error_code - httplib update changed error messages reported
# test_we_can_read_from_the_socket and test_connection_no_window_update_on_zero_length_data_frame fail due to updated dependencies
# test_client_certificate[context_kwargs1] failures seen on py36 and i586
# test_insecure_proxy_connection known flaky test
%pytest -rs -k 'not (rpmfail_getaddrinfo or test_HTTPConnection_with_custom_context or test_useful_error_with_no_protocol or test_goaway_frame_PROTOCOL_ERROR or test_goaway_frame_HTTP_1_1_REQUIRED or test_goaway_frame_invalid_error_code or test_we_can_read_from_the_socket or test_connection_no_window_update_on_zero_length_data_frame or test_set_url_info or (test_client_certificate and context_kwargs1) or test_insecure_proxy_connection)' test/

%post
%python_install_alternative hyper

%postun
%python_uninstall_alternative hyper

%files %{python_files}
%license LICENSE
%doc README.rst
%python_alternative %{_bindir}/hyper
%{python_sitelib}/hyper*

%changelog
openSUSE Build Service is sponsored by