protobuf/python-protobuf.spec

90 lines
2.7 KiB
RPMSpec

#
# spec file for package python-protobuf
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Andreas Stieger <Andreas.Stieger@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define tarname protobuf
%define baseversion 28.2
%if 0%{?gcc_version} < 11
%define with_gcc 11
%endif
%{?sle15_python_module_pythons}
Name: python-protobuf
Version: 5.%{baseversion}
Release: 0
Summary: Python Bindings for Google Protocol Buffers
License: BSD-3-Clause
Group: Development/Libraries/Python
URL: https://github.com/protocolbuffers/protobuf
Source0: https://github.com/protocolbuffers/protobuf/releases/download/v%{baseversion}/%{tarname}-%{baseversion}.tar.gz
Patch0: python-protobuf-setup_py.patch
BuildRequires: %{python_module abseil}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module python-dateutil}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: gcc%{?with_gcc}-c++
BuildRequires: protobuf-devel >= %{baseversion}
%python_subpackages
%description
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
This package contains the Python bindings for Google Protocol Buffers.
%prep
%autosetup -p1 -n %{tarname}-%{baseversion}
# The previous blank line is crucial for older system being able
# to use the autosetup macro
grep -qF "'%{version}'" python/google/protobuf/__init__.py
# kill shebang that we do not really want
sed -i -e '/env python/d' python/google/protobuf/internal/*.py
%build
protoc --upbdefs_out=python --proto_path=src google/protobuf/descriptor.proto
%if 0%{?with_gcc}
export CC=gcc-%{with_gcc}
export CXX=g++-%{with_gcc}
%endif
pushd python
export PROTOC=$(type -p protoc)
%define py_setup dist/setup.py
%python_build
popd
%install
pushd python
export PROTOC=$(type -p protoc)
%python_install
popd
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%fdupes %{buildroot}%{_prefix}
%files %{python_files}
%license LICENSE
%{python_sitearch}/google
%{python_sitearch}/protobuf*nspkg.pth
%{python_sitearch}/protobuf*info
%changelog