Blob Blame History Raw
# Enable tests by default.
%bcond_without  tests

%global         srcname         google-api-core
%global         forgeurl
Version:        2.11.1
%global         tag             v%{version}

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

License:        Apache-2.0
URL:            %forgeurl
Source0:        %forgesource

BuildRequires:  python3-devel

Epoch:          1

%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)

BuildArch:      noarch

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


%package -n python3-%{srcname}
Summary:        %{summary}
# Extras
Requires:       python3dist(grpcio)
Requires:       python3dist(grpcio-status)

%description -n python3-%{srcname}

%pyproject_extras_subpkg -n python3-%{srcname} grpc

%forgeautosetup -p1

# Allow a slightly older protobuf.
sed -i 's/"protobuf.*",/"protobuf>=3.19.4",/'

# Allow a slightly older version of grpcio.
# NOTE(mhayden): All of the tests pass fine with 1.48.3
# which is in rawhide/f38 as of 2023-02-20.
sed -i 's/1.49.1/1.48.3/g'

# Replace mock imports with unittest.mock.
grep -rl "^[[:space:]]*import mock" tests | \
    xargs sed -i -E 's/^([[:space:]]*)import mock/\1from unittest import mock/'

%pyproject_buildrequires -x testing


%pyproject_save_files google

%if %{with tests}
# Work around an unusual pytest/PEP 420 issue where pytest can't import the
# installed module. Thanks to mhroncok for the help!
mv google{,_}
%pytest tests/unit \
    -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"
mv google{_,}

%files -n python3-%{srcname} -f %{pyproject_files}
%doc README.rst