Package: pyicu Version: 1.3-1 Severity: wishlist Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu ubuntu-patch quantal
Upstream has Python 3 support, and it would be nice to enable it. (Part of the Ubuntu installer uses PyICU, and I'm working on porting it all to Python 3, so I would actually use this.) The following patch is hopefully self-explanatory, and works for me. The packaging is less trivial than it might be due to the way 2to3 is hooked up in the upstream source. I rather wish upstream had just made the tests polyglot 2/3, although I suppose that would have involved dropping support for Python < 2.6. * Add Python 3 packages. * Replace ICUtzinfo-not-heap-type.dpatch with upstream r191, which restores Python 3 compatibility. * Drop manual cleaning of python-pyicu-dbg, since dh_python2 handles this. diff -u pyicu-1.3/debian/control pyicu-1.3/debian/control --- pyicu-1.3/debian/control +++ pyicu-1.3/debian/control @@ -3,7 +3,7 @@ Priority: optional Maintainer: Debian Python Modules Team <python-modules-t...@lists.alioth.debian.org> Uploaders: Bernd Zeimetz <b...@debian.org> -Build-Depends: dpatch, debhelper (>= 5.0.37.3), python-all-dev (>= 2.6.6-3~), python-all-dbg (>= 2.6.6-3~), libicu-dev +Build-Depends: dpatch, debhelper (>= 5.0.37.3), python-all-dev (>= 2.6.6-3~), python-all-dbg (>= 2.6.6-3~), python3-all-dev (>= 3.2), python3-all-dbg (>= 3.2), libicu-dev Build-Conflicts: python-pyicu Vcs-Svn: svn://svn.debian.org/python-modules/packages/pyicu/trunk/ Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/pyicu/trunk/ @@ -33,0 +34,23 @@ + +Package: python3-pyicu +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends} +Provides: ${python:Provides} +Description: Python 3 extension wrapping the ICU C++ API + ICU is a C++ and C library that provides robust and full-featured + Unicode and locale support. This package provides an extension for + Python 3 which wraps the ICU C++ API. + +Package: python3-pyicu-dbg +Section: debug +Architecture: any +Priority: extra +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python3-pyicu (= ${binary:Version}), python3-dbg +Provides: ${python:Provides} +Description: Python 3 extension wrapping the ICU C++ API (debug extension) + ICU is a C++ and C library that provides robust and full-featured + Unicode and locale support. This package provides an extension for + Python 3 which wraps the ICU C++ API. + . + This package contains the extension built for the Python 3 debug + interpreter. diff -u pyicu-1.3/debian/rules pyicu-1.3/debian/rules --- pyicu-1.3/debian/rules +++ pyicu-1.3/debian/rules @@ -4,7 +4,9 @@ #export DH_VERBOSE=1 PKGNAME:=python-pyicu +PKG3NAME=python3-pyicu PYVERS:=$(shell pyversions -vr) +PY3VERS:=$(shell py3versions -vr) -include /usr/share/python/python.mk ifeq (,$(py_sitename)) @@ -21,20 +23,29 @@ build-stamp: dh_testdir + # setup.py modifies test source files when building for Python 3, so + # build out of tree. + rm -rf build-py2 build-py3 + mkdir -p build-py2 build-py3 + cp -a $(filter-out build-py2 build-py3 debian,$(wildcard *)) build-py2/ + cp -a $(filter-out build-py2 build-py3 debian,$(wildcard *)) build-py3/ + set -e; \ - for py in $(PYVERS); do \ + for py in $(PYVERS) $(PY3VERS); do \ + (cd build-py$${py%%.*}; \ python$$py setup.py build; \ - python$$py-dbg setup.py build; \ + python$$py-dbg setup.py build); \ done ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) set -ex ;\ for test in `ls test/*.py`; do \ - for py in $(PYVERS); do \ - PYTHONPATH=`ls -d $(CURDIR)/build/lib.*-$$py` \ + for py in $(PYVERS) $(PY3VERS); do \ + (cd build-py$${py%%.*}; \ + PYTHONPATH=`ls -d $$(pwd)/build/lib.*-$$py` \ python$$py $$test ;\ - PYTHONPATH=`ls -d $(CURDIR)/build/lib_d.*-$$py || ls -d $(CURDIR)/build/lib.*-$$py-pydebug` \ - python$$py-dbg $$test ;\ + PYTHONPATH=`ls -d $$(pwd)/build/lib_d.*-$$py || ls -d $$(pwd)/build/lib.*-$$py-pydebug` \ + python$$py-dbg $$test) ;\ done ;\ done endif @@ -46,11 +57,8 @@ dh_testdir dh_testroot rm -f install-stamp build-stamp - -for py in $(PYVERS); do \ - python$$py setup.py clean; \ - done - find . -name "*.pyc" -print0 | xargs -0 rm -f - rm -rf build + find . \( -name "*.pyc" -o -name __pycache__ \) -print0 | xargs -0 rm -f + rm -rf build-py2 build-py3 dh_clean install: install-stamp @@ -61,12 +69,15 @@ dh_installdirs set -e; \ for py in $(PYVERS); do \ + (cd build-py2; \ python$$py setup.py install --root=$(CURDIR)/debian/$(PKGNAME) --prefix=/usr $(py_setup_install_args) ;\ - python$$py-dbg setup.py install --root=$(CURDIR)/debian/$(PKGNAME)-dbg --prefix=/usr $(py_setup_install_args) ;\ + python$$py-dbg setup.py install --root=$(CURDIR)/debian/$(PKGNAME)-dbg --prefix=/usr $(py_setup_install_args)) ;\ + done + for py in $(PY3VERS); do \ + (cd build-py3; \ + python$$py setup.py install --root=$(CURDIR)/debian/$(PKG3NAME) --prefix=/usr $(py_setup_install_args) ;\ + python$$py-dbg setup.py install --root=$(CURDIR)/debian/$(PKG3NAME)-dbg --prefix=/usr $(py_setup_install_args)) ;\ done - find $(CURDIR)/debian/$(PKGNAME)-dbg -name "*.pyc" -print0 | xargs -0 rm -f - find $(CURDIR)/debian/$(PKGNAME)-dbg -name "*.py" -print0 | xargs -0 rm -f - find $(CURDIR)/debian/$(PKGNAME)-dbg -name "*.egg-info" -print0 | xargs -0 rm -f dh_installdocs dh_installexamples @@ -81,10 +92,14 @@ dh_installchangelogs CHANGES dh_compress -X.py dh_strip -p$(PKGNAME) --dbg-package=$(PKGNAME)-dbg + dh_strip -p$(PKG3NAME) --dbg-package=$(PKG3NAME)-dbg dh_fixperms dh_python2 + dh_python3 rm -rf debian/$(PKGNAME)-dbg/usr/share/doc/$(PKGNAME)-dbg ln -s $(PKGNAME) debian/$(PKGNAME)-dbg/usr/share/doc/$(PKGNAME)-dbg + rm -rf debian/$(PKG3NAME)-dbg/usr/share/doc/$(PKG3NAME)-dbg + ln -s $(PKG3NAME) debian/$(PKG3NAME)-dbg/usr/share/doc/$(PKG3NAME)-dbg dh_installdeb dh_shlibdeps dh_gencontrol diff -u pyicu-1.3/debian/patches/ICUtzinfo-not-heap-type.dpatch pyicu-1.3/debian/patches/ICUtzinfo-not-heap-type.dpatch --- pyicu-1.3/debian/patches/ICUtzinfo-not-heap-type.dpatch +++ pyicu-1.3/debian/patches/ICUtzinfo-not-heap-type.dpatch @@ -1,13 +1,74 @@ #! /bin/sh /usr/share/dpatch/dpatch-run ## ICUtzinfo-not-heap-type.dpatch by Jakub Wilk <jw...@debian.org> ## -## DP: Revert upstream change to make ICUtzinfo a heap type. +## DP: Fix bug with default tzinfo set on ICUtzinfo type. ## DP: See https://bugzilla.osafoundation.org/show_bug.cgi?id=13038 +diff --git a/common.cpp b/common.cpp +index e9d704f..84099eb 100644 +--- a/common.cpp ++++ b/common.cpp +@@ -33,6 +33,7 @@ + + static PyObject *utcoffset_NAME; + static PyObject *toordinal_NAME; ++static PyObject *getDefault_NAME; + + + typedef struct { +@@ -355,7 +356,7 @@ EXPORT UDate PyObject_AsUDate(PyObject *object) + PyObject *m = PyImport_ImportModule("icu"); + PyObject *cls = PyObject_GetAttrString(m, "ICUtzinfo"); + +- tzinfo = PyObject_GetAttrString(cls, "default"); ++ tzinfo = PyObject_CallMethodObjArgs(cls, getDefault_NAME, NULL); + Py_DECREF(cls); + Py_DECREF(m); + +@@ -1241,4 +1242,5 @@ void _init_common(PyObject *m) + + utcoffset_NAME = PyString_FromString("utcoffset"); + toordinal_NAME = PyString_FromString("toordinal"); ++ getDefault_NAME = PyString_FromString("getDefault"); + } +diff --git a/setup.py b/setup.py +index 86d0253..329ce57 100644 +--- a/setup.py ++++ b/setup.py +@@ -25,6 +25,15 @@ CFLAGS = { + 'sunos5': ['-DPYICU_VER="%s"' %(VERSION)], + } + ++# added to CFLAGS when setup is invoked with --debug ++DEBUG_CFLAGS = { ++ 'darwin': ['-O0', '-g', '-DDEBUG'], ++ 'linux': ['-O0', '-g', '-DDEBUG'], ++ 'freebsd7': ['-O0', '-g', '-DDEBUG'], ++ 'win32': ['/Od', '/DDEBUG'], ++ 'sunos5': ['-DDEBUG'], ++} ++ + LFLAGS = { + 'darwin': ['-L/usr/local/lib'], + 'linux': [], +@@ -55,6 +64,12 @@ if 'PYICU_CFLAGS' in os.environ: + else: + _cflags = CFLAGS[platform] + ++if '--debug' in sys.argv: ++ if 'PYICU_DEBUG_CFLAGS' in os.environ: ++ _cflags += os.environ['PYICU_DEBUG_CFLAGS'].split(os.pathsep) ++ else: ++ _cflags += DEBUG_CFLAGS[platform] ++ + if 'PYICU_LFLAGS' in os.environ: + _lflags = os.environ['PYICU_LFLAGS'].split(os.pathsep) + else: diff --git a/tzinfo.cpp b/tzinfo.cpp +index 2113b82..046faf1 100644 --- a/tzinfo.cpp +++ b/tzinfo.cpp -@@ -122,7 +122,6 @@ +@@ -122,7 +122,6 @@ PyTypeObject TZInfoType = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ (Py_TPFLAGS_DEFAULT | @@ -18,10 +79,40 @@ -@@ -445,7 +444,7 @@ +@@ -445,7 +444,6 @@ static PyObject *t_tzinfo__resetDefault(PyTypeObject *cls) Py_XDECREF((PyObject *) _default); _default = (t_tzinfo *) tzinfo; - PyObject_SetAttrString((PyObject *)&TZInfoType, "default", tzinfo); -+ PyDict_SetItemString(TZInfoType.tp_dict, "default", tzinfo); Py_RETURN_NONE; } - +@@ -488,7 +486,6 @@ static PyObject *t_tzinfo_setDefault(PyTypeObject *cls, PyObject *arg) + + Py_INCREF(arg); + _default = (t_tzinfo *) arg; +- PyDict_SetItemString(TZInfoType.tp_dict, "default", arg); + + if (prev) + return prev; +@@ -719,10 +716,7 @@ void _init_tzinfo(PyObject *m) + PyObject_Call((PyObject *) &FloatingTZType, args, NULL); + + if (floating && PyObject_TypeCheck(floating, &FloatingTZType)) +- { + _floating = (t_tzinfo *) floating; +- PyDict_SetItemString(TZInfoType.tp_dict, "floating", floating); +- } + else + Py_XDECREF(floating); + Py_DECREF(args); +diff --git a/tzinfo.h b/tzinfo.h +index e129465..182459f 100644 +--- a/tzinfo.h ++++ b/tzinfo.h +@@ -24,8 +24,6 @@ + #ifndef _tzinfo_h + #define _tzinfo_h + +-extern PyTypeObject TZInfoType; +- + void _init_tzinfo(PyObject *m); + + #endif /* _tzinfo_h */ Thanks, -- Colin Watson [cjwat...@ubuntu.com] -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org