Hi,
I'm packaging (locally, not for upstreaming into the official Fedora
repos) an application (
https://github.com/coreemu/core) which has a
'BuildRequires: python3-grpcio-tools`, so I am trying to come up to
speed w.r.t. the latter's Fedora packaging status. It appears that
currently all 'python3-grpc*' packages are built as subpackages of
'grpc' (currently 'grpc-1.26.0-1' in rawhide).
There appears to be a "grpcio-tools" package in PyPi
(at
https://pypi.org/project/grpcio-tools/)
that bundles some subset of "main grpc" with some of 'protobuf'
and that *could* be packaged as a "native Python" RPM package.
Alternatively, if I wanted to stick to building grpcio-tools as a
subpackage of 'grpc', I'd have to do some (very hacky) thing like
the patch to grpc.spec enclosed at the end of this message.
I'm looking for ideas/suggestions/advice on what the best (or least
bad) way to build a python3-grpcio-tools package that could be useful
as a subsequent BuildRequires for other potential/future Fedora RPMs.
Thanks much,
--Gabriel
PS. what follows is probably a BAD idea, and it would probably be much
better to just grab sources from
https://pypi.org/project/grpcio-tools/
and build a "native Python SRPM" that way, modulo the fact that pypi
duplicates subsets of both grpc and protobuf upstream sources :)
######### begin: grpc.spec.patch #########################################
--- grpc.spec.orig 2020-02-06 12:30:35.191960388 -0500
+++ grpc.spec 2020-01-23 16:17:11.303916734 -0500
@@ -1,8 +1,8 @@
Name: grpc
Version: 1.26.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Modern, open source, high-performance remote procedure call (RPC) framework
License: ASL 2.0
URL:
https://www.grpc.io
Source0:
https://github.com/grpc/grpc/archive/v%{version}/%{name}-%{version}.tar.gz
@@ -19,10 +19,13 @@
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-Cython
+# python3-grpcio-tools subpackage:
+BuildRequires: protobuf-debugsource
+
Patch0: grpc-0001-enforce-system-crypto-policies.patch
Patch2: grpc-0003-use-shell-loop-instead-makefile-function.patch
%description
gRPC is a modern open source high performance RPC framework that can run in any
@@ -72,19 +75,42 @@
Requires: %{name}%{?_isa} = %{version}-%{release}
%description -n python3-grpcio
Python3 bindings for gRPC library.
+%package -n python3-grpcio-tools
+Summary: Protobuf code generator for gRPC
+Requires: %{name}%{?_isa} = %{version}-%{release}
+
+%description -n python3-grpcio-tools
+Protobuf code generator for gRPC.
+
%prep
%autosetup -N
%patch0 -p1
#%patch1 -p1
%patch2 -p1
#%patch3 -p1
sed -i 's:^prefix ?= .*:prefix ?= %{_prefix}:' Makefile
sed -i 's:$(prefix)/lib:$(prefix)/%{_lib}:' Makefile
sed -i 's:^GTEST_LIB =.*::' Makefile
+# python3-grpcio-tools subpackage:
+pushd tools/distrib/python/grpcio_tools
+ ln -s ../../../.. grpc_root
+ sed -i '/PROTO_INCLUDE/s:third_party/protobuf/src:%{_includedir}:' \
+ protoc_lib_deps.py
+ # windows-specific (not available in protobuf-debugsource):
+ sed -i "s: 'google/protobuf/io/io_win32.cc',::" \
+ protoc_lib_deps.py
+ # removed upstream (won't be needed beyond next version bump):
+ sed -i "s: 'google/protobuf/stubs/mathlimits.cc',::" \
+ protoc_lib_deps.py
+ # linking against protobuf sources is a bit of a problem...
+ mkdir third_party
+ ln -s ../../../../../../../../../%{_usrsrc}/debug/protobuf-* \
+ third_party/protobuf
+popd
%build
%make_build shared plugins
# build python module
@@ -92,16 +118,20 @@
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=True
export GRPC_PYTHON_BUILD_SYSTEM_CARES=True
export CFLAGS="%optflags"
%py3_build
+# python3-grpcio-tools subpackage:
+(cd tools/distrib/python/grpcio_tools/; %py3_build)
%install
make install prefix="%{buildroot}%{_prefix}"
make install-grpc-cli prefix="%{buildroot}%{_prefix}"
find %{buildroot} -type f -name '*.a' -exec rm -f {} \;
%py3_install
+# python3-grpcio-tools subpackage:
+(cd tools/distrib/python/grpcio_tools/; %py3_install)
%ldconfig_scriptlets
%files
%doc README.md
@@ -147,11 +177,19 @@
%files -n python3-grpcio
%license LICENSE
%{python3_sitearch}/grpc
%{python3_sitearch}/grpcio-%{version}-py?.?.egg-info
+%files -n python3-grpcio-tools
+%license LICENSE
+%{python3_sitearch}/grpc_tools
+%{python3_sitearch}/grpcio_tools-%{version}-py?.?.egg-info
+
%changelog
+* Wed Jan 22 2020 Gabriel Somlo <gsomlo(a)gmail.com> - 1.26.0-2
+- Also build python3-grpcio-tools subpackage
+
* Wed Jan 15 2020 Sergey Avseyev <sergey.avseyev(a)gmail.com> - 1.26.0-1
- Update to 1.26.0
* Thu Dec 19 2019 Orion Poplawski <orion(a)nwra.com> - 1.20.1-5
- Rebuild for protobuf 3.11
######### end: grpc.spec.patch #########################################