THRIFT-3761 Add debian package for Python3

This closes #966
diff --git a/debian/control b/debian/control
index c1d478f..5d57460 100644
--- a/debian/control
+++ b/debian/control
@@ -3,8 +3,10 @@
 Priority: extra
 Build-Depends: debhelper (>= 9), build-essential, mono-gmcs, python-dev, ant,
     mono-devel,  libmono-system-web2.0-cil, erlang-base, ruby-dev | ruby1.9.1-dev, autoconf, automake,
-    pkg-config, libtool, bison, flex, libboost-dev | libboost1.53-dev, python-all,
-    python-all-dev, python-all-dbg, openjdk-6-jdk | java-sdk,
+    pkg-config, libtool, bison, flex, libboost-dev | libboost1.53-dev,
+    python-all, python-setuptools, python-all-dev, python-all-dbg,
+    python3-all, python3-setuptools, python3-all-dev, python3-all-dbg,
+    openjdk-6-jdk | java-sdk,
     libboost-test-dev | libboost-test1.53-dev, libevent-dev, libssl-dev, perl (>= 5.8.0-7),
     php5, php5-dev, libglib2.0-dev, qtbase5-dev, qtbase5-dev-tools
 Maintainer: Thrift Developer's <dev@thrift.apache.org>
@@ -13,6 +15,7 @@
 Vcs-Browser: https://git-wip-us.apache.org/repos/asf?p=thrift.git
 Standards-Version: 3.9.5
 X-Python-Version: >= 2.6
+X-Python3-Version: >= 3.3
 
 Package: thrift-compiler
 Architecture: any
@@ -32,7 +35,7 @@
 Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-six
 Recommends: python-twisted-web, python-backports.ssl-match-hostname, python-ipaddress
 Provides: ${python:Provides}
-Description: Python bindings for Thrift
+Description: Python bindings for Thrift (Python 2)
  Thrift is a software framework for scalable cross-language services
  development. It combines a software stack with a code generation engine to
  build services that work efficiently and seamlessly.
@@ -41,6 +44,8 @@
  tool (in the thrift-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.
+ .
+ This package installs the library for Python 2.
 
 Package: python-thrift-dbg
 Architecture: any
@@ -57,6 +62,39 @@
  definition to Python classes, and then the modules in this package will allow
  you to use those classes in your programs.
 
+Package: python3-thrift
+Architecture: any
+Section: python
+Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-six
+Recommends: python3-twisted-web
+Provides: ${python:Provides}
+Description: Python bindings for Thrift (Python 3)
+ Thrift is a software framework for scalable cross-language services
+ development. It combines a software stack with a code generation engine to
+ build services that work efficiently and seamlessly.
+ .
+ This package contains the Python bindings for Thrift. You will need the thrift
+ tool (in the thrift-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.
+ .
+ This package installs the library for Python 3.
+
+Package: python3-thrift-dbg
+Architecture: any
+Section: debug
+Depends: ${shlibs:Depends}, ${misc:Depends}, python3-thrift (= ${binary:Version}), python3-all-dbg
+Provides: ${python:Provides}
+Description: Python bindings for Thrift (debug version)
+ Thrift is a software framework for scalable cross-language services
+ development. It combines a software stack with a code generation engine to
+ build services that work efficiently and seamlessly.
+ .
+ This package contains the Python bindings for Thrift with debugging symbols.
+ You will need the thrift tool (in the thrift-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: ruby-thrift
 Architecture: all
 Section: libs
diff --git a/debian/rules b/debian/rules
index dcd2b0b..afbf323 100755
--- a/debian/rules
+++ b/debian/rules
@@ -152,10 +152,10 @@
 
 	# Python
 	cd $(CURDIR)/lib/py && \
-	for py in $(PYVERS); do \
-		$$py setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python-thrift; \
-		$$py-dbg setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python-thrift-dbg; \
-	done
+	python2 setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python-thrift && \
+	python2-dbg setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python-thrift-dbg && \
+	python3 setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python3-thrift && \
+	python3-dbg setup.py install --install-layout=deb --no-compile --root=$(CURDIR)/debian/python3-thrift-dbg
 
 	find $(CURDIR)/debian/python-thrift -name "*.py[co]" -print0 | xargs -0 rm -f
 	find $(CURDIR)/debian/python-thrift -name "__pycache__" -print0 | xargs -0 rm -fr
@@ -165,6 +165,14 @@
 	find $(CURDIR)/debian/python-thrift-dbg -name "*.egg-info" -print0 | xargs -0 rm -rf
 	find $(CURDIR)/debian/python-thrift-dbg -depth -type d -empty -exec rmdir {} \;
 
+	find $(CURDIR)/debian/python3-thrift -name "*.py[co]" -print0 | xargs -0 rm -f
+	find $(CURDIR)/debian/python3-thrift -name "__pycache__" -print0 | xargs -0 rm -fr
+	find $(CURDIR)/debian/python3-thrift-dbg -name "__pycache__" -print0 | xargs -0 rm -fr
+	find $(CURDIR)/debian/python3-thrift-dbg -name "*.py[co]" -print0 | xargs -0 rm -f
+	find $(CURDIR)/debian/python3-thrift-dbg -name "*.py" -print0 | xargs -0 rm -f
+	find $(CURDIR)/debian/python3-thrift-dbg -name "*.egg-info" -print0 | xargs -0 rm -rf
+	find $(CURDIR)/debian/python3-thrift-dbg -depth -type d -empty -exec rmdir {} \;
+
 	# PHP
 	mkdir -p $(CURDIR)/debian/php5-thrift
 	cd $(CURDIR)/lib/php && \
@@ -192,6 +200,7 @@
 	dh_installman
 	dh_link
 	dh_strip -ppython-thrift --dbg=python-thrift-dbg
+	dh_strip -ppython3-thrift --dbg=python3-thrift-dbg
 	dh_strip -pthrift-compiler -plibthrift0
 	dh_compress
 	dh_fixperms