Blob Blame History Raw
%bcond_without  tests

%global         srcname         google-api-core
%global         forgeurl        https://github.com/googleapis/python-api-core
Version:        2.4.0
%global         tag             v%{version}
%forgemeta

Name:           python-%{srcname}
Release:        %autorelease
Summary:        Core Library for Google Client Libraries

License:        ASL 2.0
URL:            %forgeurl
Source0:        %forgesource
Patch0:         use-unittest-mock-builtin.patch

BuildRequires:  python3-devel

%if %{with tests}
BuildRequires:  python3dist(google-auth)
BuildRequires:  python3dist(googleapis-common-protos)
BuildRequires:  python3dist(grpcio)
BuildRequires:  python3dist(grpcio-gcp)
BuildRequires:  python3dist(protobuf)
BuildRequires:  python3dist(proto-plus)
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(pytz)
BuildRequires:  python3dist(requests)
BuildRequires:  python3dist(six)
%endif

BuildArch:      noarch

%global _description %{expand:This library is not meant to stand-alone.
Instead it defines common helpers used by all Google API clients.}

%description
%{_description}


%package -n python3-%{srcname}
Summary:        %{summary}
# Extras
Requires:       %{py3_dist grpcio}
Requires:       %{py3_dist grpcio-gcp}

%description -n python3-%{srcname}
%{_description}

%pyproject_extras_subpkg -n python3-%{srcname} grpc
%pyproject_extras_subpkg -n python3-%{srcname} grpcgcp
%pyproject_extras_subpkg -n python3-%{srcname} grpcio-gcp

%prep
%forgeautosetup -p1


%generate_buildrequires
%pyproject_buildrequires -r


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files google


%check
%if %{with tests}
# Work around an usual pytest/PEP 420 issue where pytest can't import the
# installed module. Thanks to mhroncok for the help!
mv google{,_}
%pytest --disable-warnings tests/unit \
    --ignore=tests/unit/test_rest_streaming.py \
    -k "not test_wrap_unary_errors \
        and not test_wrap_stream_errors_invocation \
        and not test_wrap_stream_errors_iterator_initialization \
        and not test_wrap_stream_errors_during_iteration \
        and not test_exception_with_error_code \
        and not Test_StreamingResponseIterator"
mv google{_,}
%endif


%files -n python3-%{srcname} -f %{pyproject_files}
%doc README.rst CHANGELOG.md SECURITY.md
%{python3_sitelib}/google_api_core-%{version}-py%{python3_version}-nspkg.pth


%changelog
%autochangelog