Control: tag -1 + patch peter green: > There is a general push to move towards python3 in Debian, so please > investiage whether it is reasonable to pull these updates into Debian.
The attached patch adds a python3-smbus package—inspired by what was in Raspbian. -- Lunar .''`. [email protected] : :Ⓐ : # apt-get install anarchism `. `'` `-
diff -Nru i2c-tools-3.1.1/debian/changelog i2c-tools-3.1.1/debian/changelog --- i2c-tools-3.1.1/debian/changelog 2014-03-02 22:32:21.000000000 +0000 +++ i2c-tools-3.1.1/debian/changelog 2016-02-05 11:45:15.000000000 +0000 @@ -1,3 +1,9 @@ +i2c-tools (3.1.1-1.0~python3) UNRELEASED; urgency=medium + + * Add support for Python 3 inspired by the Raspbian package. + + -- Jérémy Bobbio <[email protected]> Fri, 05 Feb 2016 11:44:43 +0000 + i2c-tools (3.1.1-1) unstable; urgency=medium * New upstream version. diff -Nru i2c-tools-3.1.1/debian/control i2c-tools-3.1.1/debian/control --- i2c-tools-3.1.1/debian/control 2014-03-02 22:26:08.000000000 +0000 +++ i2c-tools-3.1.1/debian/control 2016-02-05 11:46:05.000000000 +0000 @@ -1,7 +1,7 @@ Source: i2c-tools Section: utils Priority: extra -Build-Depends: debhelper (>= 5), python-all-dev (>= 2.6.6-3~) +Build-Depends: debhelper (>= 5), python-all-dev (>= 2.6.6-3~), python3-all-dev Maintainer: Aurelien Jarno <[email protected]> Standards-Version: 3.9.5 Homepage: http://www.lm-sensors.org @@ -39,3 +39,14 @@ This Python module allows SMBus access through the I2C /dev interface on Linux hosts. The host kernel must have I2C support, I2C device interface support, and a bus adapter driver. + +Package: python3-smbus +Architecture: any +Section: python +Depends: ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends} +Provides: ${python3:Provides} +Recommends: i2c-tools +Description: Python 3 bindings for Linux SMBus access through i2c-dev + This Python module allows SMBus access through the I2C /dev interface on + Linux hosts. The host kernel must have I2C support, I2C device interface + support, and a bus adapter driver. diff -Nru i2c-tools-3.1.1/debian/patches/02-add-python3-support.diff i2c-tools-3.1.1/debian/patches/02-add-python3-support.diff --- i2c-tools-3.1.1/debian/patches/02-add-python3-support.diff 1970-01-01 00:00:00.000000000 +0000 +++ i2c-tools-3.1.1/debian/patches/02-add-python3-support.diff 2016-02-05 11:55:12.000000000 +0000 @@ -0,0 +1,106 @@ +Description: Add Python 3 support +Origin: upstream +Author: Jean Delvare <[email protected]> + +diff -Nru i2c-tools-3.1.1/py-smbus/smbusmodule.c i2c-tools-3.1.1+svn/py-smbus/smbusmodule.c +--- i2c-tools-3.1.1/py-smbus/smbusmodule.c 2014-02-20 09:56:05.873116000 +0000 ++++ i2c-tools-3.1.1+svn/py-smbus/smbusmodule.c 2015-03-27 11:06:04.000000000 +0000 +@@ -92,7 +92,11 @@ + PyObject *ref = SMBus_close(self); + Py_XDECREF(ref); + ++#if PY_MAJOR_VERSION >= 3 ++ Py_TYPE(self)->tp_free((PyObject *)self); ++#else + self->ob_type->tp_free((PyObject *)self); ++#endif + } + + #define MAXPATH 16 +@@ -432,11 +436,19 @@ + + for (ii = 0; ii < len; ii++) { + PyObject *val = PyList_GET_ITEM(list, ii); ++#if PY_MAJOR_VERSION >= 3 ++ if (!PyLong_Check(val)) { ++ PyErr_SetString(PyExc_TypeError, msg); ++ return 0; /* fail */ ++ } ++ data->block[ii+1] = (__u8)PyLong_AS_LONG(val); ++#else + if (!PyInt_Check(val)) { + PyErr_SetString(PyExc_TypeError, msg); + return 0; /* fail */ + } + data->block[ii+1] = (__u8)PyInt_AS_LONG(val); ++#endif + } + + return 1; /* success */ +@@ -635,9 +647,14 @@ + }; + + static PyTypeObject SMBus_type = { ++#if PY_MAJOR_VERSION >= 3 ++ PyVarObject_HEAD_INIT(NULL, 0) ++ "SMBus", /* tp_name */ ++#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "smbus.SMBus", /* tp_name */ ++#endif + sizeof(SMBus), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SMBus_dealloc, /* tp_dealloc */ +@@ -676,24 +693,50 @@ + SMBus_new, /* tp_new */ + }; + ++#if PY_MAJOR_VERSION >= 3 ++static struct PyModuleDef SMBusModule = { ++ PyModuleDef_HEAD_INIT, ++ "SMBus", /* m_name */ ++ SMBus_module_doc, /* m_doc */ ++ -1, /* m_size */ ++ NULL, /* m_methods */ ++ NULL, /* m_reload */ ++ NULL, /* m_traverse */ ++ NULL, /* m_clear */ ++ NULL, /* m_free */ ++}; ++#define INIT_RETURN(m) return m ++#define INIT_FNAME PyInit_smbus ++#else + static PyMethodDef SMBus_module_methods[] = { + {NULL} + }; ++#define INIT_RETURN(m) return ++#define INIT_FNAME initsmbus ++#endif + + #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ + #define PyMODINIT_FUNC void + #endif + PyMODINIT_FUNC +-initsmbus(void) ++INIT_FNAME(void) + { + PyObject* m; + + if (PyType_Ready(&SMBus_type) < 0) +- return; ++ INIT_RETURN(NULL); + ++#if PY_MAJOR_VERSION >= 3 ++ m = PyModule_Create(&SMBusModule); ++#else + m = Py_InitModule3("smbus", SMBus_module_methods, SMBus_module_doc); ++#endif ++ if (m == NULL) ++ INIT_RETURN(NULL); + + Py_INCREF(&SMBus_type); + PyModule_AddObject(m, "SMBus", (PyObject *)&SMBus_type); ++ ++ INIT_RETURN(m); + } diff -Nru i2c-tools-3.1.1/debian/patches/series i2c-tools-3.1.1/debian/patches/series --- i2c-tools-3.1.1/debian/patches/series 2014-03-02 22:30:45.000000000 +0000 +++ i2c-tools-3.1.1/debian/patches/series 2016-02-05 11:55:18.000000000 +0000 @@ -1 +1,2 @@ 01-decode-dimms-no-eeprom.diff +02-add-python3-support.diff diff -Nru i2c-tools-3.1.1/debian/rules i2c-tools-3.1.1/debian/rules --- i2c-tools-3.1.1/debian/rules 2014-03-02 22:24:36.000000000 +0000 +++ i2c-tools-3.1.1/debian/rules 2016-02-05 12:02:15.000000000 +0000 @@ -22,6 +22,7 @@ export CFLAGS CPPFLAGS LDFLAGS PYVERS = $(shell pyversions -v -r debian/control) +PY3VERS = $(shell py3versions -v -r debian/control) clean: dh_testdir @@ -51,7 +52,7 @@ CFLAGS="$(CFLAGS) -I../include" python$* setup.py build touch $@ -install: install-stamp-binaries $(PYVERS:%=install-stamp-python-%) +install: install-stamp-binaries $(PYVERS:%=install-stamp-python-%) $(PY3VERS:%=install-stamp-python3-%) install-stamp-binaries: build-stamp-binaries dh_testdir @@ -76,6 +77,16 @@ touch $@ +install-stamp-python3-%: build-stamp-python-% + dh_testdir + dh_testroot + dh_installdirs + + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp prefix=/usr + cd py-smbus && \ + CFLAGS="$(CFLAGS) -I../include" python$* setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-smbus + + touch $@ # Build architecture-independent files here. binary-indep: build install @@ -108,6 +119,7 @@ dh_perl -a dh_makeshlibs -a dh_python2 -a + dh_python3 -a dh_installdeb -a dh_shlibdeps -a dh_gencontrol -a
signature.asc
Description: Digital signature

