[tryton-debian-vcs] relatorio branch py3-WIP created. debian/0.6.0-3-5-g9f72452

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Wed Jul 16 11:34:57 UTC 2014


The following commit has been merged in the py3-WIP branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/relatorio.git;a=commitdiff;h=debian/0.6.0-3-5-g9f72452
commit 9f724528365cc12a23735478a254c54c953df761
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Wed Jul 16 13:32:09 2014 +0200

    Adding python3 packaging, waits for https://codereview.appspot.com/104580046/.

diff --git a/debian/control b/debian/control
index 64765d4..2b259f0 100644
--- a/debian/control
+++ b/debian/control
@@ -4,13 +4,15 @@ Priority: optional
 Maintainer: Debian Tryton Maintainers <maintainers at debian.tryton.org>
 Uploaders: Mathias Behrle <mathiasb at m9s.biz>
 Build-Depends:
- debhelper (>= 9), python (>= 2.6.6-3~), python-genshi, python-setuptools,
- dh-python
+ debhelper (>= 9), python (>= 2.6.6-3~), python3 (>= 3.3.0-2~), dh-python,
+ python-setuptools, python3-setuptools, python-genshi, python3-genshi,
+ python-lxml, python3-lxml, python-nose, python3-nose
 Standards-Version: 3.9.5
 Homepage: http://code.google.com/p/python-relatorio/
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=tryton/relatorio.git
 Vcs-Git: git://anonscm.debian.org/tryton/relatorio.git
-X-Python-Version: >= 2.4
+X-Python-Version: >= 2.6
+X-Python3-Version: >= 3.2
 
 Package: python-relatorio
 Architecture: all
@@ -18,7 +20,22 @@ Depends:
  ${misc:Depends}, ${python:Depends}, python-genshi, python-lxml,
  python-pkg-resources
 Suggests: python-pycha, python-yaml
-Description: Python module to create reports from Python objects
+Description: Python module to create reports from Python objects (Python2)
  This is a Python module to create reports from Python objects. Output plugins
  to several formats are included, such as documents (odt, ods, pdf) or images
  (png, svg).
+ .
+ This package is targeting Python version 2.
+
+Package: python3-relatorio
+Architecture: all
+Depends:
+ ${misc:Depends}, ${python3:Depends}, python3-genshi, python3-lxml,
+ python3-pkg-resources
+Suggests: python3-yaml
+Description: Python module to create reports from Python objects (Python3)
+ This is a Python module to create reports from Python objects. Output plugins
+ to several formats are included, such as documents (odt, ods, pdf) or images
+ (png, svg).
+ .
+ This package is targeting Python version 3.
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
new file mode 100644
index 0000000..f4b83f2
--- /dev/null
+++ b/debian/patches/python3.patch
@@ -0,0 +1,271 @@
+Description: <short summary of the patch>
+ TODO: Put a short summary on the line above and replace this paragraph
+ with a longer explanation of this change. Complete the meta-information
+ with other relevant fields (see below for details). To make it easier, the
+ information below has been extracted from the changelog. Adjust it or drop
+ it.
+ .
+ relatorio (0.6.0-3) unstable; urgency=medium
+ .
+   * Updating year in debian copyright.
+   * Removing debian/source/options, we are building with dpkg defaults.
+   * Removing PYBUILD_NAME from rules, it is no more needed.
+   * Adding pgp verification for uscan.
+   * Adding gbp.conf for usage with git-buildpackage.
+   * Updating Hompage url of the upstream project in control.
+Author: Mathias Behrle <mathiasb at m9s.biz>
+
+---
+The information above should follow the Patch Tagging Guidelines, please
+checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
+are templates for supplementary fields that you might want to add:
+
+Origin: <vendor|upstream|other>, <url of original patch>
+Bug: <url in upstream bugtracker>
+Bug-Debian: http://bugs.debian.org/<bugnumber>
+Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
+Forwarded: <no|not-needed|url proving that it has been forwarded>
+Reviewed-By: <name and email of someone who approved the patch>
+Last-Update: <YYYY-MM-DD>
+
+--- relatorio.orig/relatorio/__init__.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/__init__.py	2014-07-08 20:13:57.302942064 +0200
+@@ -9,7 +9,7 @@
+ relatorio also provides a report repository allowing you to link python objects
+ and report together, find reports by mimetypes/name/python objects.
+ """
+-from relatorio.reporting import MIMETemplateLoader, ReportRepository, Report
+-import templates
++from .reporting import MIMETemplateLoader, ReportRepository, Report
++from . import templates
+ 
+ __version__ = '0.6.0'
+--- relatorio.orig/relatorio/templates/__init__.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/templates/__init__.py	2014-07-08 20:17:01.104716091 +0200
+@@ -18,26 +18,17 @@
+ #
+ ###############################################################################
+ 
+-import traceback
+ import warnings
+-try:
+-    from cStringIO import StringIO
+-except ImportError:
+-    from StringIO import StringIO
+ 
+ plugins = ['base', 'opendocument', 'pdf', 'chart']
+ 
+ for name in plugins:
+     try:
+         __import__('relatorio.templates.%s' % name)
+-    except Exception, e:
+-        tb_file = StringIO()
+-
+-        print >> tb_file, ("Unable to load plugin '%s', you will not be able "
+-                           "to use it" % name)
+-        print >> tb_file
+-        print >> tb_file, 'Original traceback:'
+-        print >> tb_file, '-------------------'
+-        traceback.print_exc(file=tb_file)
+-        print >> tb_file
+-        warnings.warn(tb_file.getvalue())
++    except Exception as e:
++        msg = "Unable to load plugin '%s', you will not be able to use it" \
++            % name
++        msg += '\nOriginal traceback:\n'
++        msg += '-------------------\n'
++        msg += str(e)
++        warnings.warn(msg)
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ relatorio/relatorio/templates/_compat.py	2014-07-08 20:13:57.302942064 +0200
+@@ -0,0 +1,7 @@
++try:
++    from io import BytesIO
++except ImportError:
++    try:
++        from cStringIO import StringIO as BytesIO
++    except ImportError:
++        from StringIO import StringIO as BytesIO
+--- relatorio.orig/relatorio/templates/chart.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/templates/chart.py	2014-07-08 20:13:57.302942064 +0200
+@@ -20,10 +20,7 @@
+ 
+ __metaclass__ = type
+ 
+-try:
+-    from cStringIO import StringIO
+-except ImportError:
+-    from StringIO import StringIO
++from ._compat import BytesIO
+ 
+ import yaml
+ import genshi
+@@ -67,8 +64,8 @@
+         self.text_serializer = genshi.output.TextSerializer()
+ 
+     def __call__(self, stream):
+-        result = StringIO()
+-        yml = StringIO(_encode(self.text_serializer(stream)))
++        result = BytesIO()
++        yml = BytesIO(_encode(self.text_serializer(stream)))
+         chart_yaml = yaml.load(yml.read())
+         chart_info = chart_yaml['chart']
+         chart_type = chart_info['output_type']
+--- relatorio.orig/relatorio/templates/opendocument.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/templates/opendocument.py	2014-07-08 20:13:57.302942064 +0200
+@@ -22,6 +22,7 @@
+ __metaclass__ = type
+ 
+ import re
++import sys
+ try:
+     # requires python 2.5+
+     from hashlib import md5
+@@ -31,13 +32,7 @@
+ import time
+ import urllib
+ import zipfile
+-try:
+-    from io import BytesIO
+-except ImportError:
+-    try:
+-        from cStringIO import StringIO as BytesIO
+-    except ImportError:
+-        from StringIO import StringIO as BytesIO
++from ._compat import BytesIO
+ from copy import deepcopy
+ import datetime
+ from decimal import Decimal
+@@ -108,9 +103,13 @@
+ # the nsmap attribute of Element objects is (currently) readonly.
+ 
+ def guess_type(val):
+-    if isinstance(val, (str, unicode)):
+-        return 'string'
+-    elif isinstance(val, (int, float, long, Decimal)):
++    if sys.version_info < (3,):
++        if isinstance(val, (str, unicode)):
++            return 'string'
++    else:
++        if isinstance(val, str):
++            return 'string'
++    if isinstance(val, (int, float, long, Decimal)):
+         return 'float'
+ 
+ 
+@@ -355,7 +354,12 @@
+             if statement.tag == placeholder:
+                 expr = statement.text[1:-1]
+             elif statement.tag == text_a:
+-                expr = urllib.unquote(statement.attrib[xlink_href_attrib][12:])
++                if sys.version_info < (3,):
++                    expr = urllib.unquote(
++                        statement.attrib[xlink_href_attrib][12:])
++                else:
++                    expr = urllib.parse.unquote(
++                        statement.attrib[xlink_href_attrib][12:])
+ 
+             if not expr:
+                 raise OOTemplateError("No expression in the tag",
+@@ -499,8 +503,10 @@
+         repeat_tag = '{%s}repeat' % RELATORIO_URI
+ 
+         # table node (it is not necessarily the direct parent of ancestor)
+-        table_node = ancestor.iterancestors('{%s}table' % table_namespace) \
+-                             .next()
++        #table_node = ancestor.iterancestors('{%s}table' % table_namespace) \
++            #                    .next()
++        table_node = next(ancestor.iterancestors('{%s}table' %
++                table_namespace))
+         table_name = table_node.attrib['{%s}name' % table_namespace]
+ 
+         # add counting instructions
+--- relatorio.orig/relatorio/templates/pdf.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/templates/pdf.py	2014-07-08 20:13:57.302942064 +0200
+@@ -24,10 +24,7 @@
+ import shutil
+ import tempfile
+ import subprocess
+-try:
+-    from cStringIO import StringIO
+-except ImportError:
+-    from StringIO import StringIO
++from ._compat import BytesIO
+ 
+ import genshi
+ import genshi.output
+@@ -63,7 +60,7 @@
+         subprocess.check_call([TEXEXEC, '--purge', 'report.tex'],
+                               cwd=self.working_dir)
+ 
+-        pdf = StringIO()
++        pdf = BytesIO()
+         pdf.write(open(self.pdf_file, 'r').read())
+ 
+         shutil.rmtree(self.working_dir, ignore_errors=True)
+--- relatorio.orig/relatorio/tests/test_odt.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/tests/test_odt.py	2014-07-08 20:13:57.302942064 +0200
+@@ -21,11 +21,8 @@
+ 
+ 
+ import os
+-try:
+-    from cStringIO import StringIO
+-except ImportError:
+-    from StringIO import StringIO
+-
++import sys
++from ..templates._compat import BytesIO
+ import lxml.etree
+ from nose.tools import *
+ from genshi.filters import Translator
+@@ -49,10 +46,12 @@
+     return catalog.get(string, string)
+ 
+ def stream_to_string(stream):
+-    # In Python 3, stream will be bytes
+-    if not isinstance(stream, str):
+-        return str(stream, 'utf-8')
+-    return stream
++    if sys.version_info < (3,):
++        if not isinstance(stream, str):
++            return buffer(str(stream, 'utf-8'))
++        return stream
++    else:
++        return stream.decode('utf-8')
+ 
+ 
+ class TestOOTemplating(object):
+@@ -60,7 +59,8 @@
+     def setup(self):
+         thisdir = os.path.dirname(__file__)
+         filepath = os.path.join(thisdir, 'test.odt')
+-        self.oot = Template(open(filepath, mode='rb'))
++        with open(filepath, mode='rb') as fp:
++            self.oot = Template(fp)
+         self.data = {'first_name': u'Trente',
+                      'last_name': u'Møller',
+                      'ville': u'Liège',
+@@ -276,7 +276,10 @@
+         stream = self.oot.generate(**self.data)
+         rendered = stream_to_string(stream.events.render(encoding='utf-8'))
+         styles_idx = rendered.find('<?relatorio styles.xml?>')
+-        tree = lxml.etree.parse(StringIO(rendered[25:styles_idx]))
++        r = rendered[25:styles_idx]
++        if sys.version_info >= (3,):
++            r = r.encode('utf-8')
++        tree = lxml.etree.parse(BytesIO(r))
+         root = tree.getroot()
+         images = root.xpath('//draw:frame', namespaces=self.oot.namespaces)
+         eq_(len(images), 3)
+--- relatorio.orig/relatorio/tests/test_api.py	2014-07-08 20:13:57.306941929 +0200
++++ relatorio/relatorio/tests/test_api.py	2014-07-08 20:13:57.302942064 +0200
+@@ -29,7 +29,7 @@
+ class StubObject(object):
+ 
+     def __init__(self, **kwargs):
+-        for key, val in kwargs.iteritems():
++        for key, val in kwargs.items():
+             setattr(self, key, val)
+ 
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..a2fba86
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+python3.patch
diff --git a/debian/python3-relatorio.docs b/debian/python3-relatorio.docs
new file mode 100644
index 0000000..62deb04
--- /dev/null
+++ b/debian/python3-relatorio.docs
@@ -0,0 +1 @@
+AUTHORS
diff --git a/debian/rules b/debian/rules
index 85a7802..5805ced 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,9 +1,17 @@
 #!/usr/bin/make -f
 
-# Don't run tests, they try to download dependencies from pypi
-export PYBUILD_DISABLE_python2.7=test
+PACKAGE_NAME := $(shell python setup.py --name)
+export PYBUILD_NAME=$(PACKAGE_NAME)
+# Don't run tests for python3.4,
+# see https://code.google.com/p/python-relatorio/issues/detail?id=12
+#export PYBUILD_DISABLE_python3.4=test
 
 %:
-	dh ${@} --with python2 --buildsystem=pybuild
-
+	dh ${@} --with python2,python3 --buildsystem=pybuild
 
+override_dh_install:
+	dh_install
+	mkdir -p debian/python-relatorio/usr/share/python-relatorio
+	mkdir -p debian/python3-relatorio/usr/share/python3-relatorio
+	mv debian/python-relatorio/usr/lib/python2.7/dist-packages/relatorio/tests/ debian/python-relatorio/usr/share/python-relatorio
+	mv debian/python3-relatorio/usr/lib/python3.4/dist-packages/relatorio/tests/ debian/python3-relatorio/usr/share/python3-relatorio
-- 
relatorio



More information about the tryton-debian-vcs mailing list