diff --git a/_constraints b/_constraints new file mode 100644 index 0000000000000..45f9ec8330e30 --- /dev/null +++ b/_constraints @@ -0,0 +1,12 @@ + + + kvm + + + 72 + + + 24 + + + diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000000000..cefb2ec10cae6 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,13 @@ +*.substvars +*debhelper* +.debhelper +autoreconf.* +files +libprotobuf-dev +libprotobuf-lite32 +libprotobuf32 +libprotoc-dev +libprotoc32 +protobuf-compiler +python3-protobuf +tmp diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000..25673f4fb7315 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +protobuf (100:5.29.0-1) UNRELEASED; urgency=medium + + * https://github.com/protocolbuffers/protobuf/releases/tag/v5.29.0 + + -- Wong Hoi Sing Edison Thu, 28 Nov 2024 14:54:27 +0800 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000..38dd14281f5ba --- /dev/null +++ b/debian/control @@ -0,0 +1,126 @@ +Source: protobuf +Section: devel +Priority: optional +Standards-Version: 4.5.0 +Maintainer: Wong Hoi Sing Edison +Homepage: https://github.com/protocolbuffers/protobuf/tags +Vcs-Browser: https://github.com/alvistack/protocolbuffers-protobuf +Vcs-Git: https://github.com/alvistack/protocolbuffers-protobuf.git +Build-Depends: + debhelper, + debhelper-compat (= 10), + dh-python, + cmake, + fdupes, + libabsl-dev, + libjsoncpp-dev, + python3-dev, + python3-setuptools, + zlib1g-dev, + +Package: libprotobuf32t64 +Architecture: amd64 +Section: libs +Description: protocol buffers C++ library + This package contains the runtime library needed for C++ applications. +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Provides: + ${t64:Provides}, +Replaces: + libprotobuf32, +Breaks: + cura-engine (<< 1:3.3.0-2.1+b1), + libarcus3 (<< 3.3.0-2), + libprotobuf32 (<< ${source:Version}), + +Package: libprotobuf-lite32t64 +Architecture: amd64 +Section: libs +Description: protocol buffers C++ library (lite version) + This package contains the runtime library needed for C++ applications whose + message definitions have the "lite runtime" optimization setting. +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Provides: + ${t64:Provides}, +Replaces: + libprotobuf-lite32, +Breaks: + libprotobuf-lite32 (<< ${source:Version}), + +Package: libprotobuf-dev +Architecture: amd64 +Section: libdevel +Description: protocol buffers C++ library (development files) and proto files + This package contains the development headers and static libraries needed for + writing C++ applications. Includes well known proto type files. +Depends: + ${misc:Depends}, + zlib1g-dev, + libprotobuf32t64 (= ${source:Version}), + libprotobuf-lite32t64 (= ${source:Version}), +Provides: + protobuf-api-32-0, +Breaks: + protobuf-compiler (<< ${source:Version}), + protobuf-compiler (>> ${source:Version}), + +Package: libprotoc32t64 +Architecture: amd64 +Multi-Arch: same +Section: libs +Description: protocol buffers compiler library + This package contains the runtime library needed for the protocol buffer + compiler. +Depends: + ${shlibs:Depends}, + ${misc:Depends}, +Provides: + ${t64:Provides}, +Replaces: + libprotoc32, +Breaks: + libprotoc32 (<< ${source:Version}), + +Package: libprotoc-dev +Architecture: amd64 +Section: libdevel +Description: protocol buffers compiler library (development files) + This package contains the development headers and static library needed for + writing protobuf compilers. +Depends: + ${misc:Depends}, + libprotobuf-dev (= ${source:Version}), + libprotoc32t64 (= ${source:Version}), +Replaces: + libprotobuf-dev (<< 2.1.0), +Breaks: + libprotobuf-dev (<< 2.1.0), + +Package: protobuf-compiler +Architecture: amd64 +Description: compiler for protocol buffer definition files + This package contains the protocol buffer compiler that is used for + translating from .proto files (containing the definitions) to the language + binding for the supported languages. +Depends: + ${shlibs:Depends}, + ${misc:Depends}, + libprotoc32t64 (= ${source:Version}), + +Package: python3-protobuf +Architecture: amd64 +Section: python +Description: Python 3 bindings for protocol buffers + This package contains the Python 3 bindings for the protocol buffers. You will + need the protoc tool (in the protobuf-compiler package) to compile your + definition to Python classes, and then the modules in this package will allow + you to use those classes in your programs. +Depends: + ${misc:Depends}, + ${python3:Depends}, + ${shlibs:Depends}, + python3, diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000000..12900b4193ce8 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,21 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: debian/* +Copyright: 2024 Wong Hoi Sing Edison +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + The complete text of the Apache version 2.0 license + can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/debian/libprotobuf-dev.install b/debian/libprotobuf-dev.install new file mode 100644 index 0000000000000..ecd6acc265281 --- /dev/null +++ b/debian/libprotobuf-dev.install @@ -0,0 +1,6 @@ +usr/include +usr/lib/*/*.a +usr/lib/*/cmake/*/*.cmake +usr/lib/*/libprotobuf-lite.so +usr/lib/*/libprotobuf.so +usr/lib/*/pkgconfig/* diff --git a/debian/libprotobuf-dev.lintian-overrides b/debian/libprotobuf-dev.lintian-overrides new file mode 100644 index 0000000000000..30fd66a144cf2 --- /dev/null +++ b/debian/libprotobuf-dev.lintian-overrides @@ -0,0 +1,3 @@ +libprotobuf-dev: copyright-without-copyright-notice +libprotobuf-dev: initial-upload-closes-no-bugs +libprotobuf-dev: zero-byte-file-in-doc-directory diff --git a/debian/libprotobuf-lite32t64.install b/debian/libprotobuf-lite32t64.install new file mode 100644 index 0000000000000..45e00546a30a2 --- /dev/null +++ b/debian/libprotobuf-lite32t64.install @@ -0,0 +1 @@ +usr/lib/*/libprotobuf-lite.so.* diff --git a/debian/libprotobuf-lite32t64.lintian-overrides b/debian/libprotobuf-lite32t64.lintian-overrides new file mode 100644 index 0000000000000..e1c58172abd41 --- /dev/null +++ b/debian/libprotobuf-lite32t64.lintian-overrides @@ -0,0 +1,4 @@ +libprotobuf-lite32t64: copyright-without-copyright-notice +libprotobuf-lite32t64: initial-upload-closes-no-bugs +libprotobuf-lite32t64: package-name-doesnt-match-sonames +libprotobuf-lite32t64: zero-byte-file-in-doc-directory diff --git a/debian/libprotobuf32t64.install b/debian/libprotobuf32t64.install new file mode 100644 index 0000000000000..9ac8d247dccb8 --- /dev/null +++ b/debian/libprotobuf32t64.install @@ -0,0 +1 @@ +usr/lib/*/libprotobuf.so.* diff --git a/debian/libprotobuf32t64.lintian-overrides b/debian/libprotobuf32t64.lintian-overrides new file mode 100644 index 0000000000000..f0ac27f43c2ec --- /dev/null +++ b/debian/libprotobuf32t64.lintian-overrides @@ -0,0 +1,4 @@ +libprotobuf32t64: copyright-without-copyright-notice +libprotobuf32t64: initial-upload-closes-no-bugs +libprotobuf32t64: package-name-doesnt-match-sonames +libprotobuf32t64: zero-byte-file-in-doc-directory diff --git a/debian/libprotoc-dev.install b/debian/libprotoc-dev.install new file mode 100644 index 0000000000000..899bb85fe3b0f --- /dev/null +++ b/debian/libprotoc-dev.install @@ -0,0 +1,2 @@ +usr/include/google/protobuf/compiler +usr/lib/*/libprotoc.so diff --git a/debian/libprotoc-dev.lintian-overrides b/debian/libprotoc-dev.lintian-overrides new file mode 100644 index 0000000000000..f90c4d60db90b --- /dev/null +++ b/debian/libprotoc-dev.lintian-overrides @@ -0,0 +1,3 @@ +libprotoc-dev: copyright-without-copyright-notice +libprotoc-dev: initial-upload-closes-no-bugs +libprotoc-dev: zero-byte-file-in-doc-directory diff --git a/debian/libprotoc32t64.install b/debian/libprotoc32t64.install new file mode 100644 index 0000000000000..bb82d1bdb60ab --- /dev/null +++ b/debian/libprotoc32t64.install @@ -0,0 +1,3 @@ +usr/lib/*/libprotoc*.so.* +usr/lib/*/libutf8_range.so +usr/lib/*/libutf8_validity.so diff --git a/debian/libprotoc32t64.lintian-overrides b/debian/libprotoc32t64.lintian-overrides new file mode 100644 index 0000000000000..418b60e8955c1 --- /dev/null +++ b/debian/libprotoc32t64.lintian-overrides @@ -0,0 +1,4 @@ +libprotoc32t64: copyright-without-copyright-notice +libprotoc32t64: initial-upload-closes-no-bugs +libprotoc32t64: package-name-doesnt-match-sonames +libprotoc32t64: zero-byte-file-in-doc-directory diff --git a/debian/protobuf-compiler.install b/debian/protobuf-compiler.install new file mode 100644 index 0000000000000..1df36c612fb7c --- /dev/null +++ b/debian/protobuf-compiler.install @@ -0,0 +1 @@ +usr/bin/* diff --git a/debian/protobuf-compiler.lintian-overrides b/debian/protobuf-compiler.lintian-overrides new file mode 100644 index 0000000000000..6f8cc44579013 --- /dev/null +++ b/debian/protobuf-compiler.lintian-overrides @@ -0,0 +1,4 @@ +protobuf-compiler: copyright-without-copyright-notice +protobuf-compiler: initial-upload-closes-no-bugs +protobuf-compiler: no-manual-page +protobuf-compiler: zero-byte-file-in-doc-directory diff --git a/debian/python3-protobuf.install b/debian/python3-protobuf.install new file mode 100644 index 0000000000000..e3da3e75536a9 --- /dev/null +++ b/debian/python3-protobuf.install @@ -0,0 +1 @@ +usr/lib/python*/*-packages/* diff --git a/debian/python3-protobuf.lintian-overrides b/debian/python3-protobuf.lintian-overrides new file mode 100644 index 0000000000000..83767c0cd5bcc --- /dev/null +++ b/debian/python3-protobuf.lintian-overrides @@ -0,0 +1,4 @@ +python3-protobuf: copyright-without-copyright-notice +python3-protobuf: initial-upload-closes-no-bugs +python3-protobuf: shared-library-lacks-prerequisites +python3-protobuf: zero-byte-file-in-doc-directory diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000..98310a220df35 --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +SHELL := /bin/bash + +override_dh_autoreconf: + +override_dh_auto_configure: + pushd src && \ + cmake \ + .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -Dprotobuf_ABSL_PROVIDER=package \ + -Dprotobuf_JSONCPP_PROVIDER=package \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_BUILD_PROTOC_BINARIES=ON \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_TESTS=OFF && \ + popd + +override_dh_auto_build: + pushd src && \ + cmake \ + --build . \ + --parallel 10 \ + --config Release && \ + popd + ln -fs src/*.so* . + pushd python && \ + export LD_LIBRARY_PATH=.. && \ + python3 setup.py build \ + --cpp_implementation && \ + popd + +override_dh_auto_install: + pushd src && \ + export DESTDIR=../debian/tmp && \ + cmake \ + --install . && \ + popd + pushd python && \ + python3 setup.py install \ + --cpp_implementation \ + --no-compile \ + --install-layout=deb \ + --root=../debian/tmp && \ + popd + find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \; + fdupes -qnrps debian/tmp/usr/lib/python*/*-packages + + # fixup for bionic + mkdir -p $(DESTDIR)/usr/lib/python3/dist-packages + mv $(DESTDIR)/usr/lib/python*/site-packages/* $(DESTDIR)/usr/lib/python3/dist-packages/ || echo $$? + +override_dh_install: + dh_install + rm -rf debian/libprotobuf-dev/usr/include/google/protobuf/compiler + rm -rf debian/libprotobuf-dev/usr/include/java + +override_dh_auto_test: + +override_dh_auto_clean: + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000000..163aaf8d82b6c --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 0000000000000..d7c675178a31a --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1,7 @@ +protobuf source: configure-generated-file-in-source +protobuf source: dependency-is-not-multi-archified +protobuf source: file-without-copyright-information +protobuf source: no-debian-changes +protobuf source: not-binnmuable-any-depends-any +protobuf source: python3-depends-but-no-python3-helper +protobuf source: weak-library-dev-dependency diff --git a/protobuf.spec b/protobuf.spec new file mode 100644 index 0000000000000..4f39085f3312f --- /dev/null +++ b/protobuf.spec @@ -0,0 +1,304 @@ +# Copyright 2024 Wong Hoi Sing Edison +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +%global debug_package %{nil} + +%global source_date_epoch_from_changelog 0 + +Name: protobuf +Epoch: 100 +Version: 5.29.0 +Release: 1%{?dist} +Summary: Protocol Buffers - Google's data interchange format +License: BSD-3-Clause +URL: https://github.com/protocolbuffers/protobuf/tags +Source0: %{name}_%{version}.orig.tar.gz +BuildRequires: abseil-cpp-devel +BuildRequires: jsoncpp-devel +BuildRequires: cmake +BuildRequires: fdupes +BuildRequires: gcc-c++ +BuildRequires: make +BuildRequires: python-rpm-macros +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: zlib-devel + +%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. + +%prep +%autosetup -T -c -n %{name}_%{version}-%{release} +tar -zx -f %{S:0} --strip-components=1 -C . + +%build +pushd src && \ + cmake \ + .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -Dprotobuf_ABSL_PROVIDER=package \ + -Dprotobuf_JSONCPP_PROVIDER=package \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_BUILD_PROTOC_BINARIES=ON \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_TESTS=OFF && \ +popd +pushd src && \ + cmake \ + --build . \ + --parallel 10 \ + --config Release && \ +popd +ln -fs src/*.so* . +pushd python && \ + export LD_LIBRARY_PATH=.. && \ + python3 setup.py build \ + --cpp_implementation && \ +popd + +%install +pushd src && \ + export DESTDIR=%{buildroot} && \ + cmake \ + --install . && \ +popd +pushd python && \ + python3 setup.py install \ + --cpp_implementation \ + --no-compile \ + --root=%{buildroot} && \ +popd +find %{buildroot}%{python3_sitearch} -type f -name '*.pyc' -exec rm -rf {} \; +fdupes -qnrps %{buildroot}%{python3_sitearch} +rm -rf %{buildroot}%{_includedir}/java + +%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150000 +%package -n libprotobuf5_29_0_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotobuf5_29_0_0 +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. + +%package -n libprotoc5_29_0_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotoc5_29_0_0 +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. + +%package -n libprotobuf-lite5_29_0_0 +Summary: Protocol Buffers - Google's data interchange format + +%description -n libprotobuf-lite5_29_0_0 +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. + +%package -n protobuf-devel +Summary: Header files, libraries and development documentation for %{name} +Requires: libprotobuf-lite5_29_0_0 = %{epoch}:%{version}-%{release} +Requires: libprotobuf5_29_0_0 = %{epoch}:%{version}-%{release} +Requires: pkgconfig(zlib) +Provides: libprotobuf-devel = %{epoch}:%{version}-%{release} +Conflicts: protobuf2-devel + +%description -n protobuf-devel +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. + +%if 0%{?suse_version} > 1500 +%package -n python%{python3_version_nodots}-protobuf +Summary: Python3 Bindings for Google Protocol Buffers +Requires: python3 +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python%{python3_version_nodots}-protobuf +This package contains the Python bindings for Google Protocol Buffers. +%endif + +%if 0%{?sle_version} > 150000 +%package -n python3-protobuf +Summary: Python3 Bindings for Google Protocol Buffers +Requires: python3 +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python3-protobuf +This package contains the Python bindings for Google Protocol Buffers. +%endif + +%post -n libprotobuf5_29_0_0 -p /sbin/ldconfig +%postun -n libprotobuf5_29_0_0 -p /sbin/ldconfig +%post -n libprotoc5_29_0_0 -p /sbin/ldconfig +%postun -n libprotoc5_29_0_0 -p /sbin/ldconfig +%post -n libprotobuf-lite5_29_0_0 -p /sbin/ldconfig +%postun -n libprotobuf-lite5_29_0_0 -p /sbin/ldconfig + +%files -n libprotobuf5_29_0_0 +%license LICENSE +%{_libdir}/libprotobuf.so.* + +%files -n libprotoc5_29_0_0 +%{_libdir}/libprotoc.so.* + +%files -n libprotobuf-lite5_29_0_0 +%{_libdir}/libprotobuf-lite.so.* + +%files -n protobuf-devel +%dir %{_includedir}/google +%dir %{_includedir}/upb +%dir %{_includedir}/upb_generator +%dir %{_libdir}/cmake +%dir %{_libdir}/cmake/* +%{_bindir}/* +%{_includedir}/*.h +%{_includedir}/google/protobuf/ +%{_includedir}/upb/* +%{_includedir}/upb_generator/*.h +%{_libdir}/*.a +%{_libdir}/cmake/*/*.cmake +%{_libdir}/libprotobuf-lite.so +%{_libdir}/libprotobuf.so +%{_libdir}/libprotoc.so +%{_libdir}/libutf8_range.so +%{_libdir}/libutf8_validity.so +%{_libdir}/pkgconfig/protobuf-lite.pc +%{_libdir}/pkgconfig/protobuf.pc +%{_libdir}/pkgconfig/utf8_range.pc + +%if 0%{?suse_version} > 1500 +%files -n python%{python3_version_nodots}-protobuf +%license LICENSE +%{python3_sitearch}/* +%endif + +%if 0%{?sle_version} > 150000 +%files -n python3-protobuf +%license LICENSE +%{python3_sitearch}/* +%endif +%endif + +%if !(0%{?suse_version} > 1500) && !(0%{?sle_version} > 150000) +%package -n protobuf-compiler +Summary: Protocol Buffers compiler +Requires: protobuf = %{epoch}:%{version}-%{release} + +%description -n protobuf-compiler +This package contains Protocol Buffers compiler for all programming +languages + +%package -n protobuf-devel +Summary: Protocol Buffers C++ headers and libraries +Requires: protobuf = %{epoch}:%{version}-%{release} +Requires: protobuf-compiler = %{epoch}:%{version}-%{release} +Requires: zlib-devel +Requires: pkgconfig + +%description -n protobuf-devel +This package contains Protocol Buffers compiler for all languages and +C++ headers and libraries + +%package -n protobuf-lite +Summary: Protocol Buffers LITE_RUNTIME libraries + +%description -n protobuf-lite +Protocol Buffers built with optimize_for = LITE_RUNTIME. + +%package -n protobuf-lite-devel +Summary: Protocol Buffers LITE_RUNTIME development libraries +Requires: protobuf-devel = %{epoch}:%{version}-%{release} +Requires: protobuf-lite = %{epoch}:%{version}-%{release} + +%description -n protobuf-lite-devel +This package contains development libraries built with optimize_for = +LITE_RUNTIME. + +%package -n python3-protobuf +Summary: Python 3 bindings for Google Protocol Buffers +Requires: python3-six >= 1.9 +Provides: python3-protobuf = %{epoch}:%{version}-%{release} +Provides: python3dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version}dist(protobuf) = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}-protobuf = %{epoch}:%{version}-%{release} +Provides: python%{python3_version_nodots}dist(protobuf) = %{epoch}:%{version}-%{release} + +%description -n python3-protobuf +This package contains Python 3 libraries for Google Protocol Buffers + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig +%post -n protobuf-compiler -p /sbin/ldconfig +%postun -n protobuf-compiler -p /sbin/ldconfig +%post -n protobuf-lite -p /sbin/ldconfig +%postun -n protobuf-lite -p /sbin/ldconfig + +%files +%license LICENSE +%{_libdir}/libprotobuf.so.* + +%files -n protobuf-compiler +%{_bindir}/* +%{_libdir}/libprotoc.so.* +%{_libdir}/libutf8_range.so +%{_libdir}/libutf8_validity.so + +%files -n protobuf-devel +%dir %{_includedir}/google +%dir %{_includedir}/upb +%dir %{_includedir}/upb_generator +%dir %{_libdir}/cmake +%dir %{_libdir}/cmake/* +%{_includedir}/*.h +%{_includedir}/google/protobuf/ +%{_includedir}/upb/* +%{_includedir}/upb_generator/*.h +%{_libdir}/*.a +%{_libdir}/cmake/*/*.cmake +%{_libdir}/libprotobuf.so +%{_libdir}/libprotoc.so +%{_libdir}/pkgconfig/protobuf.pc +%{_libdir}/pkgconfig/utf8_range.pc + +%files -n protobuf-lite +%{_libdir}/libprotobuf-lite.so.* + +%files -n protobuf-lite-devel +%{_libdir}/libprotobuf-lite.so +%{_libdir}/pkgconfig/protobuf-lite.pc + +%files -n python3-protobuf +%{python3_sitearch}/* +%endif + +%changelog diff --git a/python/google/protobuf/internal/generator_test.py b/python/google/protobuf/internal/generator_test.py index 0f4ad64620de9..d11cb8d033350 100644 --- a/python/google/protobuf/internal/generator_test.py +++ b/python/google/protobuf/internal/generator_test.py @@ -19,6 +19,7 @@ import unittest from google.protobuf.internal import test_bad_identifiers_pb2 +from google.protobuf import service from google.protobuf import symbol_database from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_public_pb2 @@ -282,6 +283,12 @@ def testNoGenericServices(self): self.assertTrue(hasattr(unittest_no_generic_services_pb2, "FOO")) self.assertTrue(hasattr(unittest_no_generic_services_pb2, "test_extension")) + # Make sure unittest_no_generic_services_pb2 has no services subclassing + # Proto2 Service class. + if hasattr(unittest_no_generic_services_pb2, "TestService"): + self.assertFalse(issubclass(unittest_no_generic_services_pb2.TestService, + service.Service)) + def testMessageTypesByName(self): file_type = unittest_pb2.DESCRIPTOR self.assertEqual( diff --git a/python/google/protobuf/internal/service_reflection_test.py b/python/google/protobuf/internal/service_reflection_test.py index ca9e70a3807ad..1a809d5e39688 100644 --- a/python/google/protobuf/internal/service_reflection_test.py +++ b/python/google/protobuf/internal/service_reflection_test.py @@ -13,21 +13,21 @@ import unittest from google.protobuf import service_reflection +from google.protobuf import service from google.protobuf import unittest_pb2 class FooUnitTest(unittest.TestCase): def testService(self): - - class MockRpcChannel: + class MockRpcChannel(service.RpcChannel): def CallMethod(self, method, controller, request, response, callback): self.method = method self.controller = controller self.request = request callback(response) - class MockRpcController: + class MockRpcController(service.RpcController): def SetFailed(self, msg): self.failure_message = msg @@ -81,8 +81,7 @@ def Bar(self, rpc_controller, request, done): self.assertEqual(True, srvc.bar_called) def testServiceStub(self): - - class MockRpcChannel: + class MockRpcChannel(service.RpcChannel): def CallMethod(self, method, controller, request, response_class, callback): self.method = method diff --git a/python/google/protobuf/service.py b/python/google/protobuf/service.py index 8002c040ffd9b..38b8217919cbf 100644 --- a/python/google/protobuf/service.py +++ b/python/google/protobuf/service.py @@ -70,12 +70,12 @@ def CallMethod(self, method_descriptor, rpc_controller, Postconditions: * "done" will be called when the method is complete. This may be - before CallMethod() returns or it may be at some point in the future. + before CallMethod() returns or it may be at some point in the future. * If the RPC failed, the response value passed to "done" will be None. - Further details about the failure can be found by querying the - RpcController. + Further details about the failure can be found by querying the + RpcController. """ - raise NotImplementedError + raise NotImplementedError def GetRequestClass(self, method_descriptor): """Returns the class of the request message for the specified method. diff --git a/python/setup.py b/python/setup.py new file mode 100755 index 0000000000000..caf0ba7978f58 --- /dev/null +++ b/python/setup.py @@ -0,0 +1,439 @@ +#! /usr/bin/env python +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd +# +# See README for usage instructions. + +# pylint:disable=missing-module-docstring +# pylint:disable=g-bad-import-order +import fnmatch +import glob +import os +import pkg_resources +import re +import shutil +import subprocess +import sys +import sysconfig + +# pylint:disable=g-importing-member +# pylint:disable=g-multiple-import + +from setuptools import setup, Extension, find_packages + +from setuptools.command.build_ext import build_ext as _build_ext +from setuptools.command.build_py import build_py as _build_py + +# Find the Protocol Compiler. +if 'PROTOC' in os.environ and os.path.exists(os.environ['PROTOC']): + protoc = os.environ['PROTOC'] +elif os.path.exists('../src/protoc'): + protoc = '../src/protoc' +elif os.path.exists('../src/protoc.exe'): + protoc = '../src/protoc.exe' +elif os.path.exists('../bazel-bin/protoc'): + protoc = '../bazel-bin/protoc' +elif os.path.exists('../bazel-bin/protoc.exe'): + protoc = '../bazel-bin/protoc.exe' +elif os.path.exists('../protoc'): + protoc = '../protoc' +elif os.path.exists('../protoc.exe'): + protoc = '../protoc.exe' +elif os.path.exists('../vsprojects/Debug/protoc.exe'): + protoc = '../vsprojects/Debug/protoc.exe' +elif os.path.exists('../vsprojects/Release/protoc.exe'): + protoc = '../vsprojects/Release/protoc.exe' +else: + protoc = shutil.which('protoc') + + +def GetVersion(): + """Reads and returns the version from google/protobuf/__init__.py. + + Do not import google.protobuf.__init__ directly, because an installed + protobuf library may be loaded instead. + + Returns: + The version. + """ + + with open(os.path.join('google', 'protobuf', '__init__.py')) as version_file: + exec(version_file.read(), globals()) # pylint:disable=exec-used + return __version__ # pylint:disable=undefined-variable + + +def GenProto(source, require=True): + """Generates a _pb2.py from the given .proto file. + + Does nothing if the output already exists and is newer than the input. + + Args: + source: the .proto file path. + require: if True, exit immediately when a path is not found. + """ + + if not require and not os.path.exists(source): + return + + output = source.replace('.proto', '_pb2.py').replace('../src/', '') + + if (not os.path.exists(output) or + (os.path.exists(source) and + os.path.getmtime(source) > os.path.getmtime(output))): + print('Generating %s...' % output) + + if not os.path.exists(source): + sys.stderr.write("Can't find required file: %s\n" % source) + sys.exit(-1) + + if protoc is None: + sys.stderr.write( + 'protoc is not installed nor found in ../src. Please compile it ' + 'or install the binary package.\n') + sys.exit(-1) + + protoc_command = [protoc, '-I../src', '-I.', '--python_out=.', source] + if subprocess.call(protoc_command) != 0: + sys.exit(-1) + + +def GenerateUnittestProtos(): + """Generates protobuf code for unittests.""" + GenProto('../src/google/protobuf/any_test.proto', False) + GenProto('../src/google/protobuf/map_proto2_unittest.proto', False) + GenProto('../src/google/protobuf/map_unittest.proto', False) + GenProto('../src/google/protobuf/test_messages_proto3.proto', False) + GenProto('../src/google/protobuf/test_messages_proto2.proto', False) + GenProto('../src/google/protobuf/unittest.proto', False) + GenProto('../src/google/protobuf/unittest_custom_options.proto', False) + GenProto('../src/google/protobuf/unittest_import.proto', False) + GenProto('../src/google/protobuf/unittest_import_public.proto', False) + GenProto('../src/google/protobuf/unittest_mset.proto', False) + GenProto('../src/google/protobuf/unittest_mset_wire_format.proto', False) + GenProto('../src/google/protobuf/unittest_no_generic_services.proto', False) + GenProto('../src/google/protobuf/unittest_proto3_arena.proto', False) + GenProto('../src/google/protobuf/unittest_retention.proto', False) + GenProto('../src/google/protobuf/util/json_format.proto', False) + GenProto('../src/google/protobuf/util/json_format_proto3.proto', False) + GenProto('google/protobuf/internal/any_test.proto', False) + GenProto('google/protobuf/internal/descriptor_pool_test1.proto', False) + GenProto('google/protobuf/internal/descriptor_pool_test2.proto', False) + GenProto('google/protobuf/internal/factory_test1.proto', False) + GenProto('google/protobuf/internal/factory_test2.proto', False) + GenProto('google/protobuf/internal/file_options_test.proto', False) + GenProto('google/protobuf/internal/import_test_package/import_public.proto', + False) + GenProto( + 'google/protobuf/internal/import_test_package/import_public_nested.proto', + False) + GenProto('google/protobuf/internal/import_test_package/inner.proto', False) + GenProto('google/protobuf/internal/import_test_package/outer.proto', False) + GenProto('google/protobuf/internal/missing_enum_values.proto', False) + GenProto('google/protobuf/internal/message_set_extensions.proto', False) + GenProto('google/protobuf/internal/more_extensions.proto', False) + GenProto('google/protobuf/internal/more_extensions_dynamic.proto', False) + GenProto('google/protobuf/internal/more_messages.proto', False) + GenProto('google/protobuf/internal/no_package.proto', False) + GenProto('google/protobuf/internal/packed_field_test.proto', False) + GenProto('google/protobuf/internal/test_bad_identifiers.proto', False) + GenProto('google/protobuf/internal/test_proto3_optional.proto', False) + GenProto('google/protobuf/pyext/python.proto', False) + + +class BuildPyCmd(_build_py): + """Custom build_py command for building the protobuf runtime.""" + + def run(self): + # Generate necessary .proto file if it doesn't exist. + GenProto('../src/google/protobuf/descriptor.proto') + GenProto('../src/google/protobuf/compiler/plugin.proto') + GenProto('../src/google/protobuf/any.proto') + GenProto('../src/google/protobuf/api.proto') + GenProto('../src/google/protobuf/duration.proto') + GenProto('../src/google/protobuf/empty.proto') + GenProto('../src/google/protobuf/field_mask.proto') + GenProto('../src/google/protobuf/source_context.proto') + GenProto('../src/google/protobuf/struct.proto') + GenProto('../src/google/protobuf/timestamp.proto') + GenProto('../src/google/protobuf/type.proto') + GenProto('../src/google/protobuf/wrappers.proto') + GenerateUnittestProtos() + + # _build_py is an old-style class, so super() doesn't work. + _build_py.run(self) + + def find_package_modules(self, package, package_dir): + exclude = ( + '*test*', + 'google/protobuf/internal/*_pb2.py', + 'google/protobuf/internal/_parameterized.py', + 'google/protobuf/pyext/python_pb2.py', + ) + modules = _build_py.find_package_modules(self, package, package_dir) + return [(pkg, mod, fil) for (pkg, mod, fil) in modules + if not any(fnmatch.fnmatchcase(fil, pat=pat) for pat in exclude)] + + +class BuildExtCmd(_build_ext): + """Command class for building the protobuf Python extension.""" + + def get_ext_filename(self, ext_name): + # since python3.5, python extensions' shared libraries use a suffix that + # corresponds to the value of sysconfig.get_config_var('EXT_SUFFIX') and + # contains info about the architecture the library targets. E.g. on x64 + # linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so" When + # crosscompiling python wheels, we need to be able to override this + # suffix so that the resulting file name matches the target architecture + # and we end up with a well-formed wheel. + filename = _build_ext.get_ext_filename(self, ext_name) + orig_ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') + new_ext_suffix = os.getenv('PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX') + if new_ext_suffix and filename.endswith(orig_ext_suffix): + filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix + return filename + + +class TestConformanceCmd(_build_py): + target = '//python:conformance_test' + + def run(self): + # Python 2.6 dodges these extra failures. + os.environ['CONFORMANCE_PYTHON_EXTRA_FAILURES'] = ( + '--failure_list failure_list_python-post26.txt') + cmd = 'bazel test %s' % (TestConformanceCmd.target,) + subprocess.check_call(cmd, shell=True) + + +def GetOptionFromArgv(option_str): + if option_str in sys.argv: + sys.argv.remove(option_str) + return True + return False + + +def _GetFlagValues(flag_long, flag_short): + """Searches sys.argv for setuptools-style flags and yields values.""" + + expect_value = flag_long.endswith('=') + flag_res = [re.compile(r'--?%s(=(.*))?' % + (flag_long[:-1] if expect_value else flag_long))] + if flag_short: + flag_res.append(re.compile(r'-%s(.*)?' % (flag_short,))) + + flag_match = None + for arg in sys.argv: + # If the last arg was like '-O', check if this is the library we want. + if flag_match is not None: + yield arg + flag_match = None + continue + + for flag_re in flag_res: + m = flag_re.match(arg) + if m is None: + continue + if not expect_value: + yield arg + continue + groups = m.groups() + # Check for matches: + # --long-name=foo => ('=foo', 'foo') + # -Xfoo => ('foo') + # N.B.: if the flag is like '--long-name=', then there is a value + # (the empty string). + if groups[0] or groups[-1]: + yield groups[-1] + continue + flag_match = m + + return False + + +def HasStaticLibprotobufOpt(): + """Returns true if there is a --link-objects arg for libprotobuf.""" + + lib_re = re.compile(r'(.*[/\\])?(lib)?protobuf([.]pic)?[.](a|lib)') + for value in _GetFlagValues('link-objects=', 'O'): + if lib_re.match(value): + return True + return False + + +def HasLibraryDirsOpt(): + """Returns true if there is a --library-dirs arg.""" + return any(_GetFlagValues('library-dirs=', 'L')) + + +if __name__ == '__main__': + ext_module_list = [] + warnings_as_errors = '--warnings_as_errors' + if GetOptionFromArgv('--cpp_implementation'): + # Link libprotobuf.a and libprotobuf-lite.a statically with the + # extension. Note that those libraries have to be compiled with + # -fPIC for this to work. + compile_static_ext = HasStaticLibprotobufOpt() + if GetOptionFromArgv('--compile_static_extension'): + # FUTURE: add a warning and deprecate --compile_static_extension. + compile_static_ext = True + extra_objects = None + if compile_static_ext: + libraries = None + library_dirs = None + if not HasStaticLibprotobufOpt(): + if os.path.exists('../bazel-bin/src/google/protobuf/libprotobuf.a'): + extra_objects = ['../bazel-bin/src/google/protobuf/libprotobuf.a'] + else: + extra_objects = ['../libprotobuf.a'] + extra_objects += list( + glob.iglob('../third_party/utf8_range/*.a')) + # Repeat all of these enough times to eliminate order-dependence. + extra_objects += list( + glob.iglob('../third_party/abseil-cpp/absl/**/*.a')) + extra_objects += list( + glob.iglob('../third_party/abseil-cpp/absl/**/*.a')) + extra_objects += list( + glob.iglob('../third_party/abseil-cpp/absl/**/*.a')) + else: + libraries = ['protobuf'] + if HasLibraryDirsOpt(): + library_dirs = None + elif os.path.exists('../bazel-bin/src/google/protobuf/libprotobuf.a'): + library_dirs = ['../bazel-bin/src/google/protobuf'] + else: + library_dirs = ['..'] + + TestConformanceCmd.target = ('//python:conformance_test_cpp ' + '--define=use_fast_cpp_protos=true') + + extra_compile_args = [] + + message_extra_link_args = None + api_implementation_link_args = None + if 'darwin' in sys.platform: + if sys.version_info[0] == 2: + message_init_symbol = 'init_message' + api_implementation_init_symbol = 'init_api_implementation' + else: + message_init_symbol = 'PyInit__message' + api_implementation_init_symbol = 'PyInit__api_implementation' + message_extra_link_args = [ + '-Wl,-exported_symbol,_%s' % message_init_symbol + ] + api_implementation_link_args = [ + '-Wl,-exported_symbol,_%s' % api_implementation_init_symbol + ] + + if sys.platform != 'win32': + extra_compile_args.append('-Wno-write-strings') + extra_compile_args.append('-Wno-invalid-offsetof') + extra_compile_args.append('-Wno-sign-compare') + extra_compile_args.append('-Wno-unused-variable') + extra_compile_args.append('-std=c++14') + + if sys.platform == 'darwin': + extra_compile_args.append('-Wno-shorten-64-to-32') + extra_compile_args.append('-Wno-deprecated-register') + + # https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes + # C++ projects must now migrate to libc++ and are recommended to set a + # deployment target of macOS 10.9 or later, or iOS 7 or later. + if sys.platform == 'darwin': + mac_target = str(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')) + if mac_target and (pkg_resources.parse_version(mac_target) < + pkg_resources.parse_version('10.9.0')): + os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9' + os.environ['_PYTHON_HOST_PLATFORM'] = re.sub( + r'macosx-[0-9]+\.[0-9]+-(.+)', + r'macosx-10.9-\1', + sysconfig.get_platform(), + ) + + # https://github.com/Theano/Theano/issues/4926 + if sys.platform == 'win32': + extra_compile_args.append('-D_hypot=hypot') + + # https://github.com/tpaviot/pythonocc-core/issues/48 + if sys.platform == 'win32' and '64 bit' in sys.version: + extra_compile_args.append('-DMS_WIN64') + + # MSVS default is dymanic + if sys.platform == 'win32': + extra_compile_args.append('/MT') + + if 'clang' in os.popen('$CC --version 2> /dev/null').read(): + extra_compile_args.append('-Wno-shorten-64-to-32') + + if warnings_as_errors in sys.argv: + extra_compile_args.append('-Werror') + sys.argv.remove(warnings_as_errors) + + # C++ implementation extension + ext_module_list.extend([ + Extension( + 'google.protobuf.pyext._message', + glob.glob('google/protobuf/pyext/*.cc'), + include_dirs=['.', '../src', '../third_party/abseil-cpp'], + libraries=libraries, + extra_objects=extra_objects, + extra_link_args=message_extra_link_args, + library_dirs=library_dirs, + extra_compile_args=extra_compile_args, + ), + Extension( + 'google.protobuf.internal._api_implementation', + glob.glob('google/protobuf/internal/api_implementation.cc'), + extra_compile_args=(extra_compile_args + + ['-DPYTHON_PROTO2_CPP_IMPL_V2']), + extra_link_args=api_implementation_link_args, + ), + ]) + os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' + + # Keep this list of dependencies in sync with tox.ini. + install_requires = [] + + setup( + name='protobuf', + version=GetVersion(), + description='Protocol Buffers', + download_url='https://github.com/protocolbuffers/protobuf/releases', + long_description="Protocol Buffers are Google's data interchange format", + url='https://developers.google.com/protocol-buffers/', + project_urls={ + 'Source': 'https://github.com/protocolbuffers/protobuf', + }, + maintainer='protobuf@googlegroups.com', + maintainer_email='protobuf@googlegroups.com', + license='BSD-3-Clause', + classifiers=[ + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + # LINT.IfChange + # Remove importlib fallback path when we drop Python 3.8 support. + 'Programming Language :: Python :: 3.8', + # LINT.ThenChange(//depot/google3/google/protobuf/internal/test_util.py) + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + ], + namespace_packages=['google'], + packages=find_packages( + exclude=[ + 'import_test_package', + 'protobuf_distutils', + ], + ), + test_suite='google.protobuf.internal', + cmdclass={ + 'build_py': BuildPyCmd, + 'build_ext': BuildExtCmd, + 'test_conformance': TestConformanceCmd, + }, + install_requires=install_requires, + ext_modules=ext_module_list, + python_requires='>=3.8', + ) diff --git a/src/google/protobuf/unittest_arena.proto b/src/google/protobuf/unittest_arena.proto index d70e489c18805..9bf7cdb26f341 100644 --- a/src/google/protobuf/unittest_arena.proto +++ b/src/google/protobuf/unittest_arena.proto @@ -5,16 +5,14 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -edition = "2023"; +syntax = "proto2"; package proto2_arena_unittest; -// Use expanded encoding for repeated fields by default (proto2 behavior). -option features.repeated_field_encoding = EXPANDED; option cc_enable_arenas = true; message NestedMessage { - int32 d = 1; + optional int32 d = 1; } message ArenaMessage {