2a75232
# Should we re-generate the Python binding code from the .proto files, instead
2a75232
# of using the pre-generated code in the source tarball? Either approach is OK
2a75232
# under Fedora packaging guidelines.
f35647e
%bcond_with codegen
2a75232
c19ee07
%global srcname opencensus-proto
2507793
%global _description %{expand:
2507793
Census provides a framework to define and collect stats against metrics and to
c19ee07
break those stats down across user-defined dimensions.
c19ee07
c19ee07
The Census framework is natively available in many languages (e.g. C++, Go, and
c19ee07
Java). The API interface types are defined using protos to ensure consistency
c19ee07
and interoperability for the different implementations.}
c19ee07
8012fdf
Name:           python-%{srcname}
f35647e
Version:        0.4.1
7d65ef7
Release:        %autorelease
c19ee07
Summary:        Language Independent Interface Types For OpenCensus
c19ee07
a9ea9f1
License:        Apache-2.0
c19ee07
URL:            https://github.com/census-instrumentation/%{srcname}/
c19ee07
Source0:        %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz
c19ee07
c19ee07
BuildRequires:  python3-devel
2a75232
%if %{with codegen}
2a75232
BuildRequires:  %{py3_dist grpcio-tools}
2a75232
%endif
c19ee07
BuildArch:      noarch
c19ee07
2507793
%description %{_description}
c19ee07
c19ee07
c19ee07
%package -n python3-%{srcname}
c19ee07
Summary:        Python library generated from OpenCensus cross-language protos
c19ee07
2507793
%description -n python3-%{srcname} %{_description}.
c19ee07
c19ee07
c19ee07
%prep
c19ee07
%autosetup -n %{srcname}-%{version}
c19ee07
2a75232
%if %{with codegen}
2a75232
find gen-python/opencensus/proto -type f ! -name '__init__.py' -print -delete
2a75232
sed -r -i 's|\bpython |%{__python3} |g' src/mkpygen.sh
2a75232
%endif
2a75232
d368065
sed -r -i 's/^__version__[[:blank:]]*=/# &/' gen-python/version.py
d368065
cat >> gen-python/version.py <
d368065
# Python version number is always “dev”
d368065
# https://github.com/census-instrumentation/opencensus-proto/issues/234
d368065
__version__ = '%{version}'  # Correct release version
d368065
EOF
d368065
c19ee07
56418f1
%generate_buildrequires
56418f1
cd gen-python/
56418f1
%pyproject_buildrequires
56418f1
56418f1
c19ee07
%build
2a75232
%if %{with codegen}
2a75232
pushd src
2a75232
./mkpygen.sh
2a75232
popd
2a75232
%endif
c19ee07
pushd gen-python/
40ac6e9
%pyproject_wheel
c19ee07
popd
c19ee07
c19ee07
c19ee07
%install
c19ee07
pushd gen-python/
40ac6e9
%pyproject_install
b3eaf5c
# Giving the name of the containing namespace package works acceptably.
40ac6e9
# https://bugzilla.redhat.com/show_bug.cgi?id=1935266
b3eaf5c
%pyproject_save_files opencensus
c19ee07
popd
c19ee07
c19ee07
8490920
%check
8490920
# Upstream has no tests.
f35647e
%pyproject_check_import -e opencensus.proto.*.*.v1.* -e opencensus.proto.*.v1.*
8490920
8490920
b3eaf5c
%files -n python3-%{srcname} -f %{pyproject_files}
c19ee07
%license LICENSE
b3eaf5c
%doc AUTHORS CONTRIBUTING.md gen-python/README.rst
c3e4359
c3e4359
# Excluding these files makes it easier to share ownership of the namespace
c3e4359
# package directory, without worrying about trivial differences in the contents
c3e4359
# of __init__.py—which is not needed for namespace packages in recent Python
c3e4359
# versions anyway.
c19ee07
%exclude %{python3_sitelib}/opencensus/{*.py,__pycache__/}
c3e4359
c19ee07
c19ee07
%changelog
7d65ef7
%autochangelog