Blame python-google-cloud-private-ca.spec

d0afa6e
%bcond_without tests
d0afa6e
d0afa6e
%global         srcname     google-cloud-private-ca
e9cf1c0
%global         reponame    google-cloud-python
d0afa6e
d0afa6e
Name:           python-%{srcname}
3c9d755
Version:        1.8.2
d0afa6e
Release:        %autorelease
d0afa6e
Summary:        Python Client for Google Cloud Certificate Authority Service
d0afa6e
592fc8f
License:        Apache-2.0
e9cf1c0
URL:            https://github.com/googleapis/google-cloud-python
e9cf1c0
Source0:        %{url}/archive/refs/tags/%{srcname}-v%{version}.tar.gz
d0afa6e
d0afa6e
BuildArch:      noarch
d0afa6e
1bae621
BuildRequires:  python3-devel
d0afa6e
d0afa6e
%if %{with tests}
d0afa6e
BuildRequires:  python3dist(pytest)
d0afa6e
BuildRequires:  python3dist(pytest-asyncio)
d0afa6e
%endif
d0afa6e
d0afa6e
%global _description %{expand:
d0afa6e
Python Client for Google Cloud Certificate Authority Service}
d0afa6e
d0afa6e
%description %{_description}
d0afa6e
d0afa6e
d0afa6e
%package -n python3-%{srcname}
d0afa6e
Summary:        %{summary}
d0afa6e
d0afa6e
%description -n python3-%{srcname} %{_description}
d0afa6e
d0afa6e
d0afa6e
%prep
e9cf1c0
# Upstream buries the package into a subdirectory. 😭
e9cf1c0
%setup -c -T
e9cf1c0
tar xzf %{SOURCE0} --strip-components=3 \
e9cf1c0
    %{reponame}-%{srcname}-v%{version}/packages/%{srcname}
9f72c10
9656ad5
# Allow a slightly older protobuf.
9656ad5
sed -i 's/"protobuf.*",/"protobuf>=3.19.4",/' setup.py
9656ad5
9f72c10
# Replace mock imports with unittest.mock.
9f72c10
grep -rl "^[[:space:]]*import mock" tests | \
9f72c10
    xargs sed -i -E 's/^([[:space:]]*)import mock/\1from unittest import mock/'
d0afa6e
d0afa6e
d0afa6e
%generate_buildrequires
d0afa6e
%pyproject_buildrequires -r
d0afa6e
d0afa6e
d0afa6e
%build
d0afa6e
%pyproject_wheel
d0afa6e
d0afa6e
d0afa6e
%install
d0afa6e
%pyproject_install
d0afa6e
%pyproject_save_files google
d0afa6e
d0afa6e
# Remove unneeded directories and files from the final package.
d0afa6e
rm -f %{buildroot}%{_bindir}/fixup_privateca_v1beta1_keywords.py
8f88cf0
rm -rf %{buildroot}%{python3_sitelib}/{docs,samples,scripts,tests}
d0afa6e
d0afa6e
d0afa6e
%check
0ddd245
%pyproject_check_import -e google.cloud.security.privateca*
592fc8f
592fc8f
%if %{with tests}
592fc8f
# NOTE(mhayden): Setting PYTHONUSERBASE as a hack for PEP 420 namespaces.
592fc8f
# Thanks to churchyard for the fix.
592fc8f
PYTHONUSERBASE=%{buildroot}%{_prefix} \
592fc8f
    %pytest tests/unit
d0afa6e
%endif
d0afa6e
d0afa6e
d0afa6e
%files -n python3-%{srcname} -f %{pyproject_files}
d0afa6e
%license LICENSE
1bae621
%doc README.rst CHANGELOG.md samples
d0afa6e
%{python3_sitelib}/google_cloud_private_ca-%{version}-py%{python3_version}-nspkg.pth
d0afa6e
d0afa6e
d0afa6e
d0afa6e
%changelog
d0afa6e
%autochangelog