Index: debian/control
===================================================================
--- debian/control	(revision 22467)
+++ debian/control	(working copy)
@@ -3,8 +3,16 @@
 Priority: optional
 Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
 Uploaders: Piotr Lewandowski <piotr.lewandowski@gmail.com>
-Build-Depends: debhelper (>= 7), python-support
+Build-Depends: debhelper (>= 7.0.50~),
+               python-all (>= 2.6.6-3~),
+               python3-all,
+               python-nose,
+               python3-nose,
+               shared-mime-info,
+               hicolor-icon-theme
 Standards-Version: 3.9.3
+X-Python-Version: >= 2.6
+X-Python3-Version: >= 3.0
 Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/pyxdg/trunk/
 Vcs-Svn: svn://svn.debian.org/python-modules/packages/pyxdg/trunk/
 Homepage: http://www.freedesktop.org/wiki/Software/pyxdg
@@ -20,4 +28,21 @@
   * Desktop Entry Specification Version 1.0
   * Icon Theme Specification Version 0.8
   * Recent File Spec 0.2
-  * Shared-MIME-Database Specification 0.13 
+  * Shared-MIME-Database Specification 0.13
+ .
+ This package contains the Python 2 version of the library.
+
+Package: python3-xdg
+Architecture: all
+Depends: ${misc:Depends}, ${python3:Depends}, menu-xdg
+Description: Python library to access freedesktop.org standards
+ PyXDG contains implementations of freedesktop.org standards in Python:
+ .
+  * Base Directory Specification Version 0.6
+  * Menu Specification Version 1.0-draft1
+  * Desktop Entry Specification Version 1.0
+  * Icon Theme Specification Version 0.8
+  * Recent File Spec 0.2
+  * Shared-MIME-Database Specification 0.13
+ .
+ This package contains the Python 3 version of the library.
Index: debian/patches/add-IniFile-parse-docstring.patch
===================================================================
--- debian/patches/add-IniFile-parse-docstring.patch	(revision 22467)
+++ debian/patches/add-IniFile-parse-docstring.patch	(working copy)
@@ -1,17 +0,0 @@
-Author: Piotr Lewandowski <piotr.lewandowski@gmail.com>
-Description: Add documentation for 'headers' argument of IniFile.parse()
-Bug-Debian: http://bugs.debian.org/562952
-Forwarded: yes
-
---- a/xdg/IniFile.py	2010-01-24 23:39:24.000000000 +0100
-+++ b/xdg/IniFile.py	2010-02-01 14:13:33.112588929 +0100
-@@ -23,6 +23,9 @@
-         return cmp(self.content, other.content)
- 
-     def parse(self, filename, headers=None):
-+        '''
-+        headers -- list of headers the parser will try to select as a default header
-+        '''
-         # for performance reasons
-         content = self.content
- 
Index: debian/patches/fix-583497.patch
===================================================================
--- debian/patches/fix-583497.patch	(revision 22467)
+++ debian/patches/fix-583497.patch	(working copy)
@@ -1,13 +0,0 @@
-Author: Piotr Lewandowski <piotr.lewandowski@gmail.com>
-Description: Fix exception message in xdg.Mime.install_mime_info()
-Bug-Debian: http://bugs.debian.org/583497
-Forwarded: yes
-
---- a/xdg/Mime.py	2010-06-22 16:04:38.415681272 +0200
-+++ b/xdg/Mime.py	2010-06-22 16:04:58.317996589 +0200
-@@ -471,4 +471,4 @@
-         os.unlink(new_file)
-         raise Exception("The '%s' command returned an error code!\n" \
-                   "Make sure you have the freedesktop.org shared MIME package:\n" \
--                  "http://standards.freedesktop.org/shared-mime-info/") % command
-+                  "http://standards.freedesktop.org/shared-mime-info/" % command)
Index: debian/patches/fix-BaseDirectory-empty-vars.patch
===================================================================
--- debian/patches/fix-BaseDirectory-empty-vars.patch	(revision 22467)
+++ debian/patches/fix-BaseDirectory-empty-vars.patch	(working copy)
@@ -1,39 +0,0 @@
-Author: Éric Araujo <merwok@netwok.org>, Thibaut Girka <thib@sitedethib.com>
-Description: Handle empty $XDG_*_HOME variables
-Bug-Debian: http://bugs.debian.org/568757
-Forwarded: no
-Last-Update: 2011-05-08
-
---- a/xdg/BaseDirectory.py
-+++ b/xdg/BaseDirectory.py
-@@ -28,21 +28,21 @@
- from __future__ import generators
- import os
- 
--_home = os.environ.get('HOME', '/')
--xdg_data_home = os.environ.get('XDG_DATA_HOME',
--            os.path.join(_home, '.local', 'share'))
-+_home = os.path.expanduser('~')
-+xdg_data_home = os.environ.get('XDG_DATA_HOME') or \
-+            os.path.join(_home, '.local', 'share')
- 
- xdg_data_dirs = [xdg_data_home] + \
--    os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
-+    (os.environ.get('XDG_DATA_DIRS') or '/usr/local/share:/usr/share').split(':')
- 
--xdg_config_home = os.environ.get('XDG_CONFIG_HOME',
--            os.path.join(_home, '.config'))
-+xdg_config_home = os.environ.get('XDG_CONFIG_HOME') or \
-+            os.path.join(_home, '.config')
- 
- xdg_config_dirs = [xdg_config_home] + \
--    os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(':')
-+    (os.environ.get('XDG_CONFIG_DIRS') or '/etc/xdg').split(':')
- 
--xdg_cache_home = os.environ.get('XDG_CACHE_HOME',
--            os.path.join(_home, '.cache'))
-+xdg_cache_home = os.environ.get('XDG_CACHE_HOME') or \
-+            os.path.join(_home, '.cache')
- 
- xdg_data_dirs = filter(lambda x: x, xdg_data_dirs)
- xdg_config_dirs = filter(lambda x: x, xdg_config_dirs)
Index: debian/patches/fix-string-exceptions.patch
===================================================================
--- debian/patches/fix-string-exceptions.patch	(revision 22467)
+++ debian/patches/fix-string-exceptions.patch	(working copy)
@@ -1,34 +0,0 @@
-Author: Piotr Lewandowski <piotr.lewandowski@gmail.com>
-Description: Do not raise strings as exceptions
-Bug-Debian: http://bugs.debian.org/585340
-Forwarded: yes
-
---- a/xdg/Mime.py	2010-06-22 16:16:34.311503927 +0200
-+++ b/xdg/Mime.py	2010-06-22 16:19:55.445061677 +0200
-@@ -153,7 +153,7 @@
-             self.range=1
- 
-         if c!='\n':
--            raise 'Malformed MIME magic line'
-+            raise ValueError('Malformed MIME magic line')
- 
-     def getLength(self):
-         return self.start+self.lenvalue+self.range
-@@ -234,7 +234,7 @@
-         f=file(fname, 'r')
-         line=f.readline()
-         if line!='MIME-Magic\0\n':
--            raise 'Not a MIME magic file'
-+            raise ValueError('Not a MIME magic file')
- 
-         while True:
-             shead=f.readline()
-@@ -242,7 +242,7 @@
-             if not shead:
-                 break
-             if shead[0]!='[' or shead[-2:]!=']\n':
--                raise 'Malformed section heading'
-+                raise ValueError('Malformed section heading')
-             pri, tname=shead[1:-2].split(':')
-             #print shead[1:-2]
-             pri=int(pri)
Index: debian/patches/series
===================================================================
--- debian/patches/series	(revision 22467)
+++ debian/patches/series	(working copy)
@@ -1,7 +1,2 @@
 fix-DesktopEntry-docstring.patch
-fix-README.patch
-add-IniFile-parse-docstring.patch
-fix-BaseDirectory-empty-vars.patch
-fix-583497.patch
-fix-string-exceptions.patch
 set_default_menu.diff
Index: debian/patches/fix-README.patch
===================================================================
--- debian/patches/fix-README.patch	(revision 22467)
+++ debian/patches/fix-README.patch	(working copy)
@@ -1,33 +0,0 @@
-Author: Piotr Lewandowski <piotr.lewandowski@gmail.com>
-Description: Fix URLs in README
-Forwarded: yes
-
---- a/README	2009-10-28 18:22:47.000000000 +0100
-+++ b/README	2010-01-29 10:07:25.000000000 +0100
-@@ -1,20 +1,20 @@
- The XDG Package contains:
- 
- 	- Implementation of the XDG-Base-Directory Standard
--      http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/basedir-spec/
- 
- 	- Implementation of the XDG-Desktop Standard
--      http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/desktop-entry-spec/
- 
- 	- Implementation of the XDG-Menu Standard
--      http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/menu-spec/
- 
- 	- Implementation of the XDG-Icon-Theme Standard
--      http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/icon-theme-spec/
- 
- 	- Implementation of the XDG-Shared MIME-info Database
--      http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/shared-mime-info-spec/
- 
- 	- Implementation of the XDG-Recent File Storage Specification
--    http://standards.freedesktop.org/basedir-spec/
-+	  http://standards.freedesktop.org/recent-file-spec/
- 
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 22467)
+++ debian/changelog	(working copy)
@@ -1,3 +1,12 @@
+pyxdg (0.23-1) unstable; urgency=low
+
+  * New upstream version
+    + Python 3 support (closes: #591017)
+    + Test suite
+  * Convert packaging to use dh_python2 (closes: #637154)
+
+ -- Thomas Kluyver <thomas@kluyver.me.uk>  Wed, 25 Jul 2012 16:57:55 +0100
+
 pyxdg (0.19-4) unstable; urgency=low
 
   * Team upload
Index: debian/docs
===================================================================
--- debian/docs	(revision 22467)
+++ debian/docs	(working copy)
@@ -1,3 +0,0 @@
-AUTHORS
-README
-TODO
Index: debian/python-xdg.docs
===================================================================
--- debian/python-xdg.docs	(revision 0)
+++ debian/python-xdg.docs	(revision 0)
@@ -0,0 +1,3 @@
+AUTHORS
+README
+TODO
Index: debian/python3-xdg.install
===================================================================
--- debian/python3-xdg.install	(revision 0)
+++ debian/python3-xdg.install	(revision 0)
@@ -0,0 +1 @@
+usr/lib/python3
Index: debian/rules
===================================================================
--- debian/rules	(revision 22467)
+++ debian/rules	(working copy)
@@ -1,4 +1,33 @@
 #!/usr/bin/make -f
 
+#DH_VERBOSE=1
+
+PYTHON2=$(shell pyversions -vr)
+PYTHON3=$(shell py3versions -vr)
+
 %:
-	dh $@
+	dh $@ --with python2,python3
+
+ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
+test-python%:
+	nosetests-$* -v
+
+override_dh_auto_test: $(PYTHON2:%=test-python%) $(PYTHON3:%=test-python%)
+endif
+
+build-python%:
+	python$* setup.py build
+
+override_dh_auto_build: $(PYTHON3:%=build-python%)
+	dh_auto_build
+
+install-python%:
+	python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb
+
+override_dh_auto_install: $(PYTHON3:%=install-python%)
+	dh_auto_install
+
+override_dh_auto_clean:
+	dh_auto_clean
+	rm -rf build
+	rm -rf *.egg-info
Index: debian/watch
===================================================================
--- debian/watch	(revision 22467)
+++ debian/watch	(working copy)
@@ -1,3 +1,3 @@
 version=3
 
-http://people.freedesktop.org/~lanius/pyxdg-([0-9.]+).tar.gz
+http://pypi.python.org/packages/source/p/pyxdg/pyxdg-(.*)\.tar\.gz
Index: debian/python-xdg.install
===================================================================
--- debian/python-xdg.install	(revision 0)
+++ debian/python-xdg.install	(revision 0)
@@ -0,0 +1 @@
+usr/lib/python2*
Index: debian/python3-xdg.docs
===================================================================
--- debian/python3-xdg.docs	(revision 0)
+++ debian/python3-xdg.docs	(revision 0)
@@ -0,0 +1,3 @@
+AUTHORS
+README
+TODO
Index: debian/examples
===================================================================
--- debian/examples	(revision 22467)
+++ debian/examples	(working copy)
@@ -1 +0,0 @@
-test/*
