Blob Blame History Raw
# Should we re-generate the Python binding code from the .proto files, instead
# of using the pre-generated code in the source tarball? Either approach is OK
# under Fedora packaging guidelines.
%bcond_with codegen

%global srcname opencensus-proto
%global _description %{expand:
Census provides a framework to define and collect stats against metrics and to
break those stats down across user-defined dimensions.

The Census framework is natively available in many languages (e.g. C++, Go, and
Java). The API interface types are defined using protos to ensure consistency
and interoperability for the different implementations.}

Name:           python-%{srcname}
Version:        0.4.1
Release:        %autorelease
Summary:        Language Independent Interface Types For OpenCensus

License:        Apache-2.0
URL:  {srcname}/
Source0:        %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz

BuildRequires:  python3-devel
%if %{with codegen}
BuildRequires:  %{py3_dist grpcio-tools}
BuildArch:      noarch

%description %{_description}

%package -n python3-%{srcname}
Summary:        Python library generated from OpenCensus cross-language protos

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

%autosetup -n %{srcname}-%{version}

%if %{with codegen}
find gen-python/opencensus/proto -type f ! -name '' -print -delete
sed -r -i 's|\bpython |%{__python3} |g' src/

cd gen-python/

%if %{with codegen}
pushd src
pushd gen-python/

pushd gen-python/
# Giving the name of the containing namespace package works acceptably.
%pyproject_save_files opencensus

# Upstream has no tests.
%pyproject_check_import -e opencensus.proto.*.*.v1.* -e opencensus.proto.*.v1.*

%files -n python3-%{srcname} -f %{pyproject_files}
%license LICENSE
%doc AUTHORS gen-python/README.rst

# Excluding these files makes it easier to share ownership of the namespace
# package directory, without worrying about trivial differences in the contents
# of—which is not needed for namespace packages in recent Python
# versions anyway.
%exclude %{python3_sitelib}/opencensus/{*.py,__pycache__/}