[Pkg-protobuf-devel] Bug#836821: Patch to enable python 3

Jonathon Love jon at thon.love
Sun Sep 11 21:56:23 UTC 2016


hi thomas,

i submitted a patch adding support for python3 a little bit ago.

you've made a few tweaks in places that suggest you have a better 
understanding of protobuf, so your patch is likely better. (wait! i've 
just noticed my patch doesn't include changes to d/rules)

but i notice you don't patch the reflection tests, which have a typo in 
them and don't work with python3.

attached is my patch.

i never received a response wrt my patch, but hopefully you'll be more 
successful

cheers

jonathon


On 12/09/2016 03:48, Thomas Viehmann wrote:
> tag 836821 + patch
> thank you
>
> Hello,
>
> thank you for maintaining protobuf in Debian.
> As a token of appreciation, please find attached a patch to add 
> support for Python 3.
>
> Best regards
>
> Thomas
>
>
>
>
> _______________________________________________
> Pkg-protobuf-devel mailing list
> Pkg-protobuf-devel at lists.alioth.debian.org
> https://lists.alioth.debian.org/mailman/listinfo/pkg-protobuf-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-protobuf-devel/attachments/20160912/41d06d78/attachment-0001.html>
-------------- next part --------------
diff --git a/debian/control b/debian/control
index 7e73b8c..06ed52b 100644
--- a/debian/control
+++ b/debian/control
@@ -22,6 +22,10 @@ Build-Depends:
 , libpython-all-dev (>= 2.7)
 , python-setuptools
 , python-google-apputils
+ , python3-all
+ , libpython3-all-dev
+ , python3-setuptools
+ , python3-google-apputils
# Manpage generator
 , xmlto
# Tests
@@ -36,6 +40,7 @@ Homepage: https://github.com/google/protobuf/
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-protobuf/pkg-protobuf.git
Vcs-Git: https://anonscm.debian.org/git/pkg-protobuf/pkg-protobuf.git
X-Python-Version: >= 2.7
+X-Python3-Version: >= 3.2

Package: libprotobuf10
Architecture: any
@@ -164,7 +169,28 @@ Package: python-protobuf
Architecture: any
Section: python
Depends: ${shlibs:Depends}, ${python:Depends}, ${misc:Depends}
-Description: Python bindings for protocol buffers
+Description: Python bindings for protocol buffers (Python 2)
+ Protocol buffers are a flexible, efficient, automated mechanism for
+ serializing structured data - similar to XML, but smaller, faster, and
+ simpler. You define how you want your data to be structured once, then you can
+ use special generated source code to easily write and read your structured
+ data to and from a variety of data streams and using a variety of languages.
+ You can even update your data structure without breaking deployed programs
+ that are compiled against the "old" format.
+ .
+ Google uses Protocol Buffers for almost all of its internal RPC protocols and
+ file formats.
+ .
+ This package contains the Python 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.
+
+Package: python3-protobuf
+Architecture: any
+Section: python
+Depends: ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends}
+Description: Python bindings for protocol buffers (Python 3)
 Protocol buffers are a flexible, efficient, automated mechanism for
 serializing structured data - similar to XML, but smaller, faster, and
 simpler. You define how you want your data to be structured once, then you can
diff --git a/debian/patches/fix-tests-for-python3.patch b/debian/patches/fix-tests-for-python3.patch
new file mode 100644
index 0000000..ed719e8
--- /dev/null
+++ b/debian/patches/fix-tests-for-python3.patch
@@ -0,0 +1,11 @@
+--- a/python/google/protobuf/internal/reflection_test.py
++++ b/python/google/protobuf/internal/reflection_test.py
+@@ -636,7 +636,7 @@
+     if struct.calcsize('L') == 4:
+       # Python only has signed ints, so 32-bit python can't fit an uint32
+       # in an int.
+-      TestGetAndDeserialize('optional_uint32', 1 << 31, long)
++      TestGetAndDeserialize('optional_uint32', 1 << 31, integer_64)
+     else:
+       # 64-bit python can fit uint32 inside an int
+       TestGetAndDeserialize('optional_uint32', 1 << 31, int)
diff --git a/debian/patches/series b/debian/patches/series
index 56fe525..f930685 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
+fix-tests-for-python3.patch
Restore-New-Callback-into-google-protobuf-namespace.patch
expect_death.patch
hurd.patch
diff --git a/debian/rules b/debian/rules
index 8445efb..eec5de6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,7 +1,7 @@
#!/usr/bin/make -f

%:
-	dh $@ --with autoreconf,python2 --parallel
+	dh $@ --with autoreconf,python2,python3 --parallel

override_dh_auto_build-arch:
## Chicken<->Egg problem: protobuf requires self-generated .pb.go files to
@@ -15,7 +15,8 @@ override_dh_auto_build-arch:
   xmlto man debian/protoc.xml

   # Python build.
-	cd python && python setup.py build --cpp_implementation
+	cd python && python  setup.py build --cpp_implementation
+	cd python && python3 setup.py build --cpp_implementation

override_dh_auto_build-indep:
   dh_auto_build --indep
@@ -44,6 +45,9 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
   export LD_LIBRARY_PATH=$(CURDIR)/src/.libs; \
   cd python && for python in $(shell pyversions -r); do \
       $$python setup.py test --cpp_implementation; \
+	done; \
+	for python in $(shell py3versions -r); do \
+		$$python setup.py test --cpp_implementation; \
   done
endif

@@ -69,7 +73,7 @@ override_dh_auto_clean-indep:
override_dh_auto_install-arch:
   dh_auto_install --arch

-	# Python install.
+	# Python 2 install.
   set -e; \
   cd python && for python in $(shell pyversions -r); do \
       $$python setup.py install --cpp_implementation \
@@ -78,6 +82,15 @@ override_dh_auto_install-arch:
   done
   find $(CURDIR)/debian/python-protobuf -name 'protobuf-*-nspkg.pth' -delete

+	# Python 3 install.
+	set -e; \
+	cd python && for python in $(shell py3versions -r); do \
+		$$python setup.py install --cpp_implementation \
+			--install-layout=deb --no-compile \
+			--root=$(CURDIR)/debian/python3-protobuf; \
+	done
+	find $(CURDIR)/debian/python3-protobuf -name 'protobuf-*-nspkg.pth' -delete
+
override_dh_auto_install-indep:
   dh_auto_install --indep


More information about the Pkg-protobuf-devel mailing list