On Mon, 2017-02-27 at 13:09 +0000, Brian Russell wrote: > Package: python-inotifyx > Severity: important > Tags: patch > > Dear Maintainer, > > I've updated inotifyx to build a python3 package (tested with python3.5 > on debian stretch).
Hello Brian, Thank you for the patches. The Debian version is lagging by a release. The current upstream release is 0.2.2. But looking at the changes, I'm hoping it hasn't much diverged from what you have the patch against. I am including the upstream author to get it reviewed/included. Unfortunately, I don't think this will make into Debian Stretch as it is frozen now and the freeze policy does not allow new packages to enter into the archive. Dear Forrest, Hope you are doing good. Could you please review patches on this bug report ? Thanks, Ritesh -- Ritesh Raj Sarraf | http://people.debian.org/~rrs Debian - The Universal Operating System
>From 1f0197385d4f9848aa3a128865466ccb062c7a72 Mon Sep 17 00:00:00 2001 From: Luca Boccassi <lbocc...@brocade.com> Date: Fri, 24 Feb 2017 17:37:13 +0000 Subject: [PATCH 3/4] Convert to dh-python2 and debhelper 9 format In order to support both python2 and python3 builds out of the box we need to modernize the packaging a bit. Use debhelper 9 and dh-python2 and set the build system to pybuilder with distutils. The resulting package is the same as the previous one. --- debian/compat | 2 +- debian/control | 4 +++- debian/rules | 63 ++++------------------------------------------------------ 3 files changed, 8 insertions(+), 61 deletions(-) diff --git a/debian/compat b/debian/compat index 7f8f011..ec63514 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -7 +9 diff --git a/debian/control b/debian/control index c59966c..cf17152 100644 --- a/debian/control +++ b/debian/control @@ -3,8 +3,9 @@ Section: python Priority: optional Maintainer: Ritesh Raj Sarraf <r...@debian.org> Uploaders: Debian Python Modules Team <python-modules-t...@lists.alioth.debian.org> -Build-Depends: debhelper (>= 7), python-all-dev (>= 2.6.6-3~) +Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~), dh-python Standards-Version: 3.9.2 +X-Python-Version: >= 2.7 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/inotifyx.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/inotifyx.git Homepage: http://www.alittletooquiet.net/software/inotifyx/ @@ -12,6 +13,7 @@ Homepage: http://www.alittletooquiet.net/software/inotifyx/ Package: python-inotifyx Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +X-Python-Version: >= 2. Provides: ${python:Provides} Description: simple Python binding to the Linux inotify inotifyx is a Python extension providing access to the Linux diff --git a/debian/rules b/debian/rules index 9786d05..32b1ae2 100755 --- a/debian/rules +++ b/debian/rules @@ -1,67 +1,12 @@ #!/usr/bin/make -f -PKG_NAME=inotifyx PKG_VER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p') -PYVERS=$(shell pyversions -vr) - --include /usr/share/python/python.mk +export PYBUILD_NAME = inotifyx +export PYBUILD_SYSTEM = distutils get-orig-source: uscan --force-download --rename --download-version=$(PKG_VER) --destdir=. -build: build-arch build-indep - -build-arch: $(PYVERS:%=build-python%) - touch $@ - -build-indep: $(PYVERS:%=build-python%) - touch $@ - -build-python%: - dh_testdir - python$* setup.py build - touch $@ - -clean: $(PYVERS:%=clean-python%) - touch $@ - -clean-python%: - dh_testdir - dh_testroot - - python$* setup.py clean --all - [ ! -e html ] || rm -rf html - [ ! -f setuplib.pyc ] || rm -rf setuplib.pyc - - dh_clean - -install: $(PYVERS:%=install-python%) - touch $@ - -install-python%: build - dh_testdir - dh_testroot - dh_installdirs - - python$* setup.py install --root $(CURDIR)/debian/python-inotifyx ${py_setup_install_args} - -binary-indep: build install - -binary-arch: build install - dh_testdir - dh_testroot - dh_installdocs - dh_installchangelogs NEWS - dh_python2 - dh_compress - dh_fixperms - dh_strip - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install get-orig-source +%: + dh $@ --with python2 --buildsystem=pybuild -- 2.1.4
>From d2ffb3aa85fba9c288c892c3a2268647e5fa88ac Mon Sep 17 00:00:00 2001 From: Luca Boccassi <lbocc...@brocade.com> Date: Fri, 24 Feb 2017 17:38:58 +0000 Subject: [PATCH 4/4] Add initial python3 support Build and package for both python2 and python3. --- debian/control | 25 ++++++++++++++++++++++++- debian/rules | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index cf17152..bf4414e 100644 --- a/debian/control +++ b/debian/control @@ -3,9 +3,10 @@ Section: python Priority: optional Maintainer: Ritesh Raj Sarraf <r...@debian.org> Uploaders: Debian Python Modules Team <python-modules-t...@lists.alioth.debian.org> -Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~), dh-python +Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~), python3-all-dev, dh-python Standards-Version: 3.9.2 X-Python-Version: >= 2.7 +X-Python3-Version: >= 3.2 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/inotifyx.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/inotifyx.git Homepage: http://www.alittletooquiet.net/software/inotifyx/ @@ -31,3 +32,25 @@ Description: simple Python binding to the Linux inotify * The API provided by pyinotify seems to change in incompatible ways on a fairly regular basis and with little justification. inotifyx has a simple API that will change rarely, if ever. + +Package: python3-inotifyx +Architecture: any +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends} +Provides: ${python3:Provides} +X-Python3-Version: >= 3.2 +Description: simple Python binding to the Linux inotify + inotifyx is a Python extension providing access to the Linux + inotify file system event notification API. It is primarily + written in C but has some Python window dressing + . + inotifyx exists as an alternative to the much known pyinotify bindings + . + Reasons you might choose inotifyx over pyinotify + * inotifyx is a C extension and does not use ctypes, making it + faster and less prone to subtle breakage due to changes in the inotify API + * inotifyx is a much thinner wrapper around inotify. pyinotify is more + complicated. It does provide features that inotifyx does not, but many of + them are not needed by most applications + * The API provided by pyinotify seems to change in incompatible ways on a + fairly regular basis and with little justification. inotifyx has a simple + API that will change rarely, if ever. diff --git a/debian/rules b/debian/rules index 32b1ae2..36fc8eb 100755 --- a/debian/rules +++ b/debian/rules @@ -9,4 +9,4 @@ get-orig-source: uscan --force-download --rename --download-version=$(PKG_VER) --destdir=. %: - dh $@ --with python2 --buildsystem=pybuild + dh $@ --with python2,python3 --buildsystem=pybuild -- 2.1.4
>From a0cf60121148f3ceb19ac68803418137955a012c Mon Sep 17 00:00:00 2001 From: Brian Russell <bruss...@brocade.com> Date: Mon, 27 Feb 2017 12:21:15 +0000 Subject: [PATCH 2/4] update C binding for python3 Update the module init for python3. This is required for version 3.5 onwards. --- inotifyx/binding.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/inotifyx/binding.c b/inotifyx/binding.c index 95082ce..ef0094a 100644 --- a/inotifyx/binding.c +++ b/inotifyx/binding.c @@ -44,6 +44,9 @@ #define EVENT_SIZE (sizeof (struct inotify_event)) #define BUF_LEN (1024 * (EVENT_SIZE + 16)) +#if PY_MAJOR_VERSION >= 3 +#define IS_PY3 +#endif static PyObject * inotifyx_init(PyObject *self, PyObject *args) { int fd; @@ -262,7 +265,25 @@ static PyMethodDef InotifyMethods[] = { {NULL, NULL, 0, NULL} }; +#ifdef IS_PY3 +static struct PyModuleDef inotifybinding = +{ + PyModuleDef_HEAD_INIT, + "inotifyx.binding", + ( + "Low-level interface to inotify. Do not use this module directly.\n" + "Instead, use the inotifyx module." + ), + -1, + InotifyMethods +}; + +PyMODINIT_FUNC PyInit_binding(void) { + PyObject *module = PyModule_Create(&inotifybinding); + if (module == NULL) + return NULL; +#else PyMODINIT_FUNC initbinding(void) { PyObject* module = Py_InitModule3( "inotifyx.binding", @@ -275,6 +296,7 @@ PyMODINIT_FUNC initbinding(void) { if (module == NULL) return; +#endif PyModule_AddIntConstant(module, "IN_ACCESS", IN_ACCESS); PyModule_AddIntConstant(module, "IN_MODIFY", IN_MODIFY); @@ -299,4 +321,7 @@ PyMODINIT_FUNC initbinding(void) { PyModule_AddIntConstant(module, "IN_ISDIR", IN_ISDIR); PyModule_AddIntConstant(module, "IN_ONESHOT", IN_ONESHOT); PyModule_AddIntConstant(module, "IN_ALL_EVENTS", IN_ALL_EVENTS); +#ifdef IS_PY3 + return module; +#endif } -- 2.1.4
>From 6273caed4b42acad700560d30ddad1daf382dde5 Mon Sep 17 00:00:00 2001 From: Brian Russell <bruss...@brocade.com> Date: Fri, 24 Feb 2017 17:01:41 +0000 Subject: [PATCH 1/4] python3 compatibility Automated 2to3 changes plus manual fixup to make the code python3 compatible. --- inotifyx/__init__.py | 6 +++--- setup.py | 4 ++-- setuplib.py | 12 ++++++------ tests/__init__.py | 2 +- tests/manager.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/inotifyx/__init__.py b/inotifyx/__init__.py index df10385..fcfaa04 100644 --- a/inotifyx/__init__.py +++ b/inotifyx/__init__.py @@ -95,7 +95,7 @@ class InotifyEvent(object): ''' parts = [] - for name, value in constants.items(): + for name, value in list(constants.items()): if self.mask & value: parts.append(name) if parts: @@ -124,7 +124,7 @@ if __name__ == '__main__': import sys if len(sys.argv) == 1: - print >>sys.stderr, 'usage: inotify path [path ...]' + sys.stderr.write('usage: inotify path [path ...]') sys.exit(1) paths = sys.argv[1:] @@ -146,7 +146,7 @@ if __name__ == '__main__': parts = [event.get_mask_description()] if event.name: parts.append(event.name) - print '%s: %s' % (path, ' '.join(parts)) + print('%s: %s' % (path, ' '.join(parts))) except KeyboardInterrupt: pass diff --git a/setup.py b/setup.py index 5564aba..bbd64c1 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ # Author: Forest Bond <forest.b...@outpostembedded.com> # This file is in the public domain. -import os, sys, commands +import os, sys, subprocess from distutils.core import Extension @@ -22,7 +22,7 @@ def get_version(release_file): finally: f.close() except (IOError, OSError): - status, output = commands.getstatusoutput('bzr revno') + status, output = subprocess.getstatusoutput('bzr revno') if status == 0: return 'bzr%s' % output.strip() return 'unknown' diff --git a/setuplib.py b/setuplib.py index cbfd67b..bbd6c74 100644 --- a/setuplib.py +++ b/setuplib.py @@ -1,7 +1,7 @@ # Author: Forest Bond <forest.b...@outpostembedded.com> # This file is in the public domain. -from __future__ import with_statement + import os, sys, shutil from tempfile import mkdtemp @@ -216,8 +216,8 @@ class _DistinfoMixin: def _prepare_distinfo_string(self, value): if isinstance(value, str): - value = unicode(value) - return unicode(repr(value)).encode('utf-8') + value = str(value) + return str(repr(value)).encode('utf-8') def _write_distinfo_module(self, outfile, distinfo = (), imports = ()): distinfo = list(distinfo) @@ -236,7 +236,7 @@ class _DistinfoMixin: log.info(' %s = %s', k, v) if not self.dry_run: - with open(outfile, 'wb') as f: + with open(outfile, 'w') as f: f.write('# coding: utf-8\n') f.write('\n') for modname in imports: @@ -359,8 +359,8 @@ class install_data(_install_data): def _gen_data_files(self, base_dir, data_files): for arg in data_files: - print arg - if isinstance(arg, basestring): + print(arg) + if isinstance(arg, str): yield (base_dir, [arg]) else: subdir, filenames = arg diff --git a/tests/__init__.py b/tests/__init__.py index 4c2d77e..3537ebb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -46,4 +46,4 @@ def main(**kwargs): def print_names(test_names = None): from tests.manager import manager - print '\n'.join(manager.get_names(test_names)) + print('\n'.join(manager.get_names(test_names))) diff --git a/tests/manager.py b/tests/manager.py index 804ec12..a05f156 100644 --- a/tests/manager.py +++ b/tests/manager.py @@ -77,7 +77,7 @@ class TestManager(object): import coverage as _coverage if int(_coverage.__version__.split('.')[0]) < 3: - print >>sys.stderr, ( + sys.stderr.write( 'warning: coverage versions < 3 ' 'are known to produce imperfect results' ) @@ -94,7 +94,7 @@ class TestManager(object): for test in self.tests: if self.should_run_test(test, test_names): if print_only: - print test.id() + print(test.id()) else: suite.addTest(test) -- 2.1.4
signature.asc
Description: This is a digitally signed message part