From f171a4a501760f4d7c58b21adba2266df73baa08 Mon Sep 17 00:00:00 2001
From: Andrew Starr-Bochicchio <asb@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Date: Fri, 10 May 2013 14:37:50 -0400
Subject: [PATCH] Build python3 packages.

---
 debian/changelog                      |  6 +++++
 debian/control                        | 46 ++++++++++++++++++++++++++++++++++-
 debian/python-libtorrent-dbg.install  |  2 +-
 debian/python-libtorrent.install      |  4 +--
 debian/python3-libtorrent-dbg.install |  1 +
 debian/python3-libtorrent.install     |  2 ++
 debian/rules                          |  8 +++---
 7 files changed, 62 insertions(+), 7 deletions(-)
 create mode 100644 debian/python3-libtorrent-dbg.install
 create mode 100644 debian/python3-libtorrent.install

diff --git a/debian/changelog b/debian/changelog
index 990e8ff..4270875 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libtorrent-rasterbar (0.16.9-2) UNRELEASED; urgency=low
+
+  * Build python3 packages.
+
+ -- Andrew Starr-Bochicchio <asb@debian.org>  Fri, 10 May 2013 14:36:07 -0400
+
 libtorrent-rasterbar (0.16.9-1) experimental; urgency=low
 
   * New upstream version 0.16.9.
diff --git a/debian/control b/debian/control
index 62d91f8..a533430 100644
--- a/debian/control
+++ b/debian/control
@@ -11,12 +11,16 @@ Build-Depends: debhelper (>= 7.4.10),
                pkg-config,
                python-all-dev (>= 2.6.6-3~),
                python-all-dbg,
-               python-docutils
+               python-docutils,
+               python3-all-dev,
+               python3-all-dbg,
+               python3-docutils
 Standards-Version: 3.9.2
 Vcs-Git: git://git.debian.org/git/collab-maint/libtorrent-rasterbar.git
 Vcs-Browser: http://git.debian.org/?p=collab-maint/libtorrent-rasterbar.git
 Homepage: http://www.rasterbar.com/products/libtorrent/index.html
 X-Python-Version: >= 2.4
+X-Python3-Version: >= 3.1
 
 Package: libtorrent-rasterbar7
 Architecture: any
@@ -132,3 +136,43 @@ Description: Python bindings for libtorrent-rasterbar (debug symbols)
  .
  This package contains Python bindings for the libtorrent-rasterbar library
  (debug symbols).
+
+Package: python3-libtorrent
+Section: python
+Architecture: any
+Pre-Depends: dpkg (>= 1.15.6~)
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, libtorrent-rasterbar7 (= ${binary:Version})
+Provides: ${python3:Provides}
+Breaks: ${python3:Breaks}
+Description: Python bindings for libtorrent-rasterbar (Python 3)
+ Bittorrent library by Rasterbar Software (Arvid Norberg).
+ libtorrent-rasterbar is a C++ library that aims to be a good alternative to
+ all the other bittorrent implementations around.
+ .
+ The main goals of libtorrent-rasterbar are:
+  * to be cpu efficient
+  * to be memory efficient
+  * to be very easy to use
+ .
+ This package contains Python bindings for the libtorrent-rasterbar library.
+
+Package: python3-libtorrent-dbg
+Section: debug
+Priority: extra
+Architecture: any
+Pre-Depends: dpkg (>= 1.15.6~)
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, python-libtorrent (= ${binary:Version}), python3-dbg
+Provides: ${python3:Provides}
+Breaks: ${python3:Breaks}
+Description: Python bindings for libtorrent-rasterbar (debug symbols) (Python 3)
+ Bittorrent library by Rasterbar Software (Arvid Norberg).
+ libtorrent-rasterbar is a C++ library that aims to be a good alternative to
+ all the other bittorrent implementations around.
+ .
+ The main goals of libtorrent-rasterbar are:
+  * to be cpu efficient
+  * to be memory efficient
+  * to be very easy to use
+ .
+ This package contains Python bindings for the libtorrent-rasterbar library
+ (debug symbols).
diff --git a/debian/python-libtorrent-dbg.install b/debian/python-libtorrent-dbg.install
index 966c7ac..c4a9213 100644
--- a/debian/python-libtorrent-dbg.install
+++ b/debian/python-libtorrent-dbg.install
@@ -1 +1 @@
-usr/lib/python*/*-packages/libtorrent_d.so
+usr/lib/python2*/*-packages/libtorrent_d.so
diff --git a/debian/python-libtorrent.install b/debian/python-libtorrent.install
index c230fa0..04cea14 100644
--- a/debian/python-libtorrent.install
+++ b/debian/python-libtorrent.install
@@ -1,2 +1,2 @@
-usr/lib/python*/*-packages/libtorrent.so
-usr/lib/python*/*-packages/*.egg-info
+usr/lib/python2*/*-packages/libtorrent.so
+usr/lib/python2*/*-packages/*.egg-info
diff --git a/debian/python3-libtorrent-dbg.install b/debian/python3-libtorrent-dbg.install
new file mode 100644
index 0000000..00f2fec
--- /dev/null
+++ b/debian/python3-libtorrent-dbg.install
@@ -0,0 +1 @@
+usr/lib/python3*/*-packages/*.cpython-*d*.so
diff --git a/debian/python3-libtorrent.install b/debian/python3-libtorrent.install
new file mode 100644
index 0000000..2fc0097
--- /dev/null
+++ b/debian/python3-libtorrent.install
@@ -0,0 +1,2 @@
+usr/lib/python3*/*-packages/*[!d]m{,u}.so
+usr/lib/python3*/*-packages/*.egg-info
diff --git a/debian/rules b/debian/rules
index 6d5a3fa..cdeaaf4 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,18 +5,20 @@ include /usr/share/dpkg/buildflags.mk
 
 export DEB_LDFLAGS_MAINT_APPEND  = -Wl,--as-needed
 
-PYVERSIONS=$(shell pyversions -vr)
-ALLPY=$(PYVERSIONS) $(PYVERSIONS:%=%-dbg)
+PYTHON2=$(shell pyversions -vr)
+PYTHON3=$(shell py3versions -vr)
+ALLPY=$(PYTHON2) $(PYTHON3) $(PYTHON2:%=%-dbg) $(PYTHON3:%=%-dbg)
 
 CONFIGURE_ARGS = --with-libgeoip
 
 %:
-	dh $@ --parallel --with python2
+	dh $@ --parallel --with python2,python3
 
 override_dh_auto_configure-nopy:
 	dh_auto_configure --builddirectory build -- $(CONFIGURE_ARGS)
 
 override_dh_auto_configure-%:
+	CPPFLAGS="$(CPPFLAGS) $(shell python$*-config --includes)" \
 	dh_auto_configure --builddirectory build-py$* -- \
 		PYTHON=/usr/bin/python$* PYTHON_INSTALL_PARAMS="--root=$(CURDIR)/debian/tmp --install-layout=deb" \
 		--enable-python-binding --with-boost-python=boost_python-mt-py$(subst .,,$(subst -dbg,,$*)) \
-- 
1.8.1.2

