* i2c-tools: add compatibility for python2/3 to py-smbus
@ 2015-01-19 15:13 Angelo Compagnucci
[not found] ` <CA+TH9VkT1K2aqAuNOLsGiU407OA4NYcMVaUakEQgSWLpMBBg2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Angelo Compagnucci @ 2015-01-19 15:13 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, jdelvare-l3A5Bk7waGM
[-- Attachment #1: Type: text/plain, Size: 487 bytes --]
Dear Jean Delvare,
Attached you can find a patch that implements py-smbus for python3
with python2 backward compatibility.
This patch is not heavily tested, but it wors well for me.
Unfortunately, I don't know how to use svn for sharing source code, it
is so ugly compared to git and it doesn't provide a way to send
patches via email, so the best way I found was to attach the patch
file.
Hope this helps!
Sincerely, Angelo
--
Profile: http://it.linkedin.com/in/compagnucciangelo
[-- Attachment #2: i2c-tools-py-smbus-python2-3-support.patch --]
[-- Type: text/x-patch, Size: 3785 bytes --]
Index: smbusmodule.c
===================================================================
diff --git a/i2c-tools/trunk/py-smbus/smbusmodule.c b/i2c-tools/trunk/py-smbus/smbusmodule.c
--- a/i2c-tools/trunk/py-smbus/smbusmodule.c (revision 6261)
+++ b/i2c-tools/trunk/py-smbus/smbusmodule.c (working copy)
@@ -18,14 +18,16 @@
#include <Python.h>
#include "structmember.h"
-#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
-#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-#include <i2c/smbus.h>
+/* Required for backward compatibility with python 2*/
+#if PY_MAJOR_VERSION >= 3
+#define PY3
+#endif
+
/*
** These are required to build this module against Linux older than 2.6.23.
*/
@@ -35,6 +37,7 @@
#define I2C_SMBUS_I2C_BLOCK_DATA 8
#endif
+#ifndef PY3
PyDoc_STRVAR(SMBus_module_doc,
"This module defines an object type that allows SMBus transactions\n"
"on hosts running the Linux kernel. The host kernel must have I2C\n"
@@ -44,6 +47,7 @@
"\n"
"Because the I2C device interface is opened R/W, users of this\n"
"module usually must have root permissions.\n");
+#endif
typedef struct {
PyObject_HEAD
@@ -94,7 +98,11 @@
PyObject *ref = SMBus_close(self);
Py_XDECREF(ref);
+#ifndef PY3
self->ob_type->tp_free((PyObject *)self);
+#else
+ Py_TYPE(self)->tp_free((PyObject *)self);
+#endif
}
#define MAXPATH 16
@@ -434,11 +442,19 @@
for (ii = 0; ii < len; ii++) {
PyObject *val = PyList_GET_ITEM(list, ii);
+#ifndef PY3
if (!PyInt_Check(val)) {
PyErr_SetString(PyExc_TypeError, msg);
return 0; /* fail */
}
data->block[ii+1] = (__u8)PyInt_AS_LONG(val);
+#else
+ if (!PyLong_Check(val)) {
+ PyErr_SetString(PyExc_TypeError, msg);
+ return 0; /* fail */
+ }
+ data->block[ii+1] = (__u8)PyLong_AS_LONG(val);
+#endif
}
return 1; /* success */
@@ -636,12 +652,18 @@
{NULL},
};
+#ifndef PY3
static PyTypeObject SMBus_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"smbus.SMBus", /* tp_name */
- sizeof(SMBus), /* tp_basicsize */
- 0, /* tp_itemsize */
+#else
+static PyTypeObject SMBus_type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "SMBus", /* tp_name */
+#endif
+ sizeof(SMBus), /* tp_basicsize */
+ 0, /* tp_itemsize */
(destructor)SMBus_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
@@ -678,24 +700,64 @@
SMBus_new, /* tp_new */
};
+#ifndef PY3
static PyMethodDef SMBus_module_methods[] = {
{NULL}
};
+#else
+static struct PyModuleDef SMBusModule = {
+ PyModuleDef_HEAD_INIT,
+ "SMBus", /* m_name */
+ "This module defines an object type that allows SMBus transactions\n"
+ "on hosts running the Linux kernel. The host kernel must have I2C\n"
+ "support, I2C device interface support, and a bus adapter driver.\n"
+ "All of these can be either built-in to the kernel, or loaded from\n"
+ "modules.\n"
+ "\n"
+ "Because the I2C device interface is opened R/W, users of this\n"
+ "module usually must have root permissions.\n", /* m_doc */
+ -1, /* m_size */
+ NULL, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+};
+#endif
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC
-initsmbus(void)
+
+#ifndef PY3
+initsmbus(void)
+#else
+PyInit_smbus(void)
+#endif
{
PyObject* m;
if (PyType_Ready(&SMBus_type) < 0)
+#ifndef PY3
return;
+#else
+ return NULL;
+#endif
+#ifndef PY3
m = Py_InitModule3("smbus", SMBus_module_methods, SMBus_module_doc);
+#else
+ m = PyModule_Create(&SMBusModule);
+ if (m == NULL)
+ return NULL;
+#endif
Py_INCREF(&SMBus_type);
PyModule_AddObject(m, "SMBus", (PyObject *)&SMBus_type);
+
+#ifdef PY3
+ return m;
+#endif
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <CA+TH9VkT1K2aqAuNOLsGiU407OA4NYcMVaUakEQgSWLpMBBg2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-01-19 22:03 ` Jean Delvare
[not found] ` <20150119230327.0224d0ba-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2015-01-19 22:03 UTC (permalink / raw)
To: Angelo Compagnucci
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard, Michael Mercier
Hi Angelo,
On Mon, 19 Jan 2015 16:13:26 +0100, Angelo Compagnucci wrote:
> Dear Jean Delvare,
>
> Attached you can find a patch that implements py-smbus for python3
> with python2 backward compatibility.
> This patch is not heavily tested, but it wors well for me.
Thanks a lot for your work. I was finally about to look into this and
you saved me some time :-)
> Unfortunately, I don't know how to use svn for sharing source code, it
> is so ugly compared to git and it doesn't provide a way to send
> patches via email, so the best way I found was to attach the patch
> file.
This is fine. You know, this is how people did before git was invented,
and it worked well ;-)
> Hope this helps!
Oh yeah. I started from your version and improved it as follows:
* Added back missing header files as pointed out by Michael. I have a
hard time believing you did not need these.
* Reverted some undesirable white space changes.
* Turned most #ifndefs into #ifdefs for readability.
* Shared the module documentation string.
* Added some preprocessing magic to limit the number of #ifdefs.
* Dropped PY3 definition.
Result is below, my patch is significantly smaller and the resulting
code is IMHO more readable. It builds fine for both python 2.7 and 3.3,
however I can't test it, so I would appreciate if you guys could test
and report. If it works fine I'll commit it tomorrow.
For convenience I have also put the pre-patched file at:
http://jdelvare.nerim.net/devel/i2c-tools/smbusmodule.c
Thanks.
---
py-smbus/smbusmodule.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
--- i2c-tools.orig/py-smbus/smbusmodule.c 2015-01-19 22:09:39.624016377 +0100
+++ i2c-tools/py-smbus/smbusmodule.c 2015-01-19 22:59:03.651572099 +0100
@@ -94,7 +94,11 @@ SMBus_dealloc(SMBus *self)
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
@@ -434,11 +438,19 @@ SMBus_list_to_data(PyObject *list, union
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 */
@@ -637,9 +649,14 @@ static PyGetSetDef SMBus_getset[] = {
};
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 */
@@ -678,24 +695,50 @@ static PyTypeObject SMBus_type = {
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);
}
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <20150119230327.0224d0ba-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-01-22 8:56 ` Michael Mercier
[not found] ` <1421917018.21840.0-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Mercier @ 2015-01-22 8:56 UTC (permalink / raw)
To: Jean Delvare
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
Hi Jean,
I just tried you patch and I got an error when I try to import the
smbus python package:
import smbus
ImportError:
/usr/local/lib/python3.2/dist-packages/smbus.cpython-32mu.so: undefined
symbol: i2c_smbus_process_call
Any idea?
Thanks,
Michael Mercier
Le lun. 19 janv. 2015 à 23:03, Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org> a
écrit :
> Hi Angelo,
>
> On Mon, 19 Jan 2015 16:13:26 +0100, Angelo Compagnucci wrote:
>> Dear Jean Delvare,
>>
>> Attached you can find a patch that implements py-smbus for python3
>> with python2 backward compatibility.
>> This patch is not heavily tested, but it wors well for me.
>
> Thanks a lot for your work. I was finally about to look into this and
> you saved me some time :-)
>
>> Unfortunately, I don't know how to use svn for sharing source code,
>> it
>> is so ugly compared to git and it doesn't provide a way to send
>> patches via email, so the best way I found was to attach the patch
>> file.
>
> This is fine. You know, this is how people did before git was
> invented,
> and it worked well ;-)
>
>> Hope this helps!
>
> Oh yeah. I started from your version and improved it as follows:
> * Added back missing header files as pointed out by Michael. I have a
> hard time believing you did not need these.
> * Reverted some undesirable white space changes.
> * Turned most #ifndefs into #ifdefs for readability.
> * Shared the module documentation string.
> * Added some preprocessing magic to limit the number of #ifdefs.
> * Dropped PY3 definition.
>
> Result is below, my patch is significantly smaller and the resulting
> code is IMHO more readable. It builds fine for both python 2.7 and
> 3.3,
> however I can't test it, so I would appreciate if you guys could test
> and report. If it works fine I'll commit it tomorrow.
>
> For convenience I have also put the pre-patched file at:
> http://jdelvare.nerim.net/devel/i2c-tools/smbusmodule.c
>
> Thanks.
> ---
> py-smbus/smbusmodule.c | 47
> +++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 45 insertions(+), 2 deletions(-)
>
> --- i2c-tools.orig/py-smbus/smbusmodule.c 2015-01-19
> 22:09:39.624016377 +0100
> +++ i2c-tools/py-smbus/smbusmodule.c 2015-01-19 22:59:03.651572099
> +0100
> @@ -94,7 +94,11 @@ SMBus_dealloc(SMBus *self)
> 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
> @@ -434,11 +438,19 @@ SMBus_list_to_data(PyObject *list, union
>
> 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 */
> @@ -637,9 +649,14 @@ static PyGetSetDef SMBus_getset[] = {
> };
>
> 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 */
> @@ -678,24 +695,50 @@ static PyTypeObject SMBus_type = {
> 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);
> }
>
>
> --
> Jean Delvare
> SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <1421917018.21840.0-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
@ 2015-01-22 10:25 ` Jean Delvare
2015-01-22 10:49 ` Jean Delvare
1 sibling, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2015-01-22 10:25 UTC (permalink / raw)
To: Michael Mercier
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
Hi Michael,
On Thu, 22 Jan 2015 09:56:58 +0100, Michael Mercier wrote:
> Hi Jean,
>
> I just tried you patch and I got an error when I try to import the
> smbus python package:
Thanks for testing and reporting.
> import smbus
>
> ImportError:
> /usr/local/lib/python3.2/dist-packages/smbus.cpython-32mu.so: undefined
> symbol: i2c_smbus_process_call
>
> Any idea?
Not really, again I know nothing about python. But didn't you have the
same problem with Angelo's patch?
Maybe Angelo has an idea.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <1421917018.21840.0-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
2015-01-22 10:25 ` Jean Delvare
@ 2015-01-22 10:49 ` Jean Delvare
[not found] ` <20150122114958.3178f5f6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
1 sibling, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2015-01-22 10:49 UTC (permalink / raw)
To: Michael Mercier
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
Hi again Michael,
On Thu, 22 Jan 2015 09:56:58 +0100, Michael Mercier wrote:
> I just tried you patch and I got an error when I try to import the
> smbus python package:
>
> import smbus
>
> ImportError:
> /usr/local/lib/python3.2/dist-packages/smbus.cpython-32mu.so: undefined
> symbol: i2c_smbus_process_call
>
> Any idea?
Hmm, OK, I think I see what's going on here.
There are two i2c-tools branches: the stable branch (3.1) and the
development branch (SVN trunk.) The patch I sent was for the
development branch.
One important difference between the two branches is that, in the
stable branch, the i2c API is implemented as a set of inline functions,
while in the development branch it is a library. I don't think that
py-smbus was properly ported so most likely it was already broken
before my patch. I suppose you are using SVN trunk and this is why you
have this linking problem?
If that is the case, then maybe the following patch will do the trick:
---
py-smbus/Module.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- i2c-tools.orig/py-smbus/Module.mk 2012-04-26 12:05:55.351086796 +0200
+++ i2c-tools/py-smbus/Module.mk 2015-01-22 11:47:06.524806243 +0100
@@ -12,7 +12,7 @@ PY_SMBUS_DIR := py-smbus
PYTHON ?= python
DISTUTILS := \
cd $(PY_SMBUS_DIR) && \
- CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
+ CPPFLAGS="$(CPPFLAGS) -I../include" LDFLAGS="$(LDFLAGS) -Llib -li2c" $(PYTHON) setup.py
all-python: $(INCLUDE_DIR)/i2c/smbus.h
$(DISTUTILS) build
But please keep in mind that my python knowledge is non-existent so it
might be plain wrong. Hopefully Angelo can comment on this.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <20150122114958.3178f5f6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-01-22 13:28 ` Michael Mercier
[not found] ` <1421933290.21840.1-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Mercier @ 2015-01-22 13:28 UTC (permalink / raw)
To: Jean Delvare
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
Thanks a lot!
It was a linking problem. I applied the patch and I it works for both
python2 and python3.
For those who are interested you can choose to the python version with
the PYTHON variable:
make install # use "python" so it depends on your system configuration
make install PYTHON=python2 # for python 2 explicitly
make install PYTHON=python3 # for python 3 explicitly
I have only tested read_i2c_block_data write_i2c_block_data for python
3.2 and python 2.7.
I think you can push these patchs upstream.
Thanks again,
Michael Mercier
Le jeu. 22 janv. 2015 à 11:49, Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org> a
écrit :
> Hi again Michael,
>
> On Thu, 22 Jan 2015 09:56:58 +0100, Michael Mercier wrote:
>> I just tried you patch and I got an error when I try to import the
>> smbus python package:
>>
>> import smbus
>>
>> ImportError:
>> /usr/local/lib/python3.2/dist-packages/smbus.cpython-32mu.so:
>> undefined
>> symbol: i2c_smbus_process_call
>>
>> Any idea?
>
> Hmm, OK, I think I see what's going on here.
>
> There are two i2c-tools branches: the stable branch (3.1) and the
> development branch (SVN trunk.) The patch I sent was for the
> development branch.
>
> One important difference between the two branches is that, in the
> stable branch, the i2c API is implemented as a set of inline
> functions,
> while in the development branch it is a library. I don't think that
> py-smbus was properly ported so most likely it was already broken
> before my patch. I suppose you are using SVN trunk and this is why you
> have this linking problem?
>
> If that is the case, then maybe the following patch will do the trick:
>
> ---
> py-smbus/Module.mk | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- i2c-tools.orig/py-smbus/Module.mk 2012-04-26 12:05:55.351086796
> +0200
> +++ i2c-tools/py-smbus/Module.mk 2015-01-22 11:47:06.524806243 +0100
> @@ -12,7 +12,7 @@ PY_SMBUS_DIR := py-smbus
> PYTHON ?= python
> DISTUTILS := \
> cd $(PY_SMBUS_DIR) && \
> - CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
> + CPPFLAGS="$(CPPFLAGS) -I../include" LDFLAGS="$(LDFLAGS) -Llib
> -li2c" $(PYTHON) setup.py
>
> all-python: $(INCLUDE_DIR)/i2c/smbus.h
> $(DISTUTILS) build
>
> But please keep in mind that my python knowledge is non-existent so it
> might be plain wrong. Hopefully Angelo can comment on this.
>
> --
> Jean Delvare
> SUSE L3 Support
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c"
> in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <1421933290.21840.1-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
@ 2015-01-22 13:37 ` Jean Delvare
2015-01-26 11:46 ` Jean Delvare
1 sibling, 0 replies; 9+ messages in thread
From: Jean Delvare @ 2015-01-22 13:37 UTC (permalink / raw)
To: Michael Mercier
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
On Thu, 22 Jan 2015 14:28:10 +0100, Michael Mercier wrote:
> Thanks a lot!
>
> It was a linking problem. I applied the patch and I it works for both
> python2 and python3.
>
> For those who are interested you can choose to the python version with
> the PYTHON variable:
> make install # use "python" so it depends on your system configuration
> make install PYTHON=python2 # for python 2 explicitly
> make install PYTHON=python3 # for python 3 explicitly
>
>
> I have only tested read_i2c_block_data write_i2c_block_data for python
> 3.2 and python 2.7.
>
> I think you can push these patchs upstream.
Great, thanks for testing :)
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <1421933290.21840.1-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
2015-01-22 13:37 ` Jean Delvare
@ 2015-01-26 11:46 ` Jean Delvare
[not found] ` <20150126124615.7fd1f64f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
1 sibling, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2015-01-26 11:46 UTC (permalink / raw)
To: Michael Mercier
Cc: Angelo Compagnucci, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
On Thu, 22 Jan 2015 14:28:10 +0100, Michael Mercier wrote:
> I have only tested read_i2c_block_data write_i2c_block_data for python
> 3.2 and python 2.7.
>
> I think you can push these patchs upstream.
I committed both patches. I also added python 3 support to the stable
branch.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: i2c-tools: add compatibility for python2/3 to py-smbus
[not found] ` <20150126124615.7fd1f64f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-04-09 20:32 ` Angelo Compagnucci
0 siblings, 0 replies; 9+ messages in thread
From: Angelo Compagnucci @ 2015-04-09 20:32 UTC (permalink / raw)
To: Jean Delvare
Cc: Michael Mercier, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Renz, Bernhard
Hi Jean,
2015-01-26 12:46 GMT+01:00 Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>:
> On Thu, 22 Jan 2015 14:28:10 +0100, Michael Mercier wrote:
>> I have only tested read_i2c_block_data write_i2c_block_data for python
>> 3.2 and python 2.7.
>>
>> I think you can push these patchs upstream.
>
> I committed both patches. I also added python 3 support to the stable
> branch.
Any news on when the new i2c-tools stable release with python3 support
will be released?
Sincerely, Angelo
>
> --
> Jean Delvare
> SUSE L3 Support
--
Profile: http://it.linkedin.com/in/compagnucciangelo
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-04-09 20:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 15:13 i2c-tools: add compatibility for python2/3 to py-smbus Angelo Compagnucci
[not found] ` <CA+TH9VkT1K2aqAuNOLsGiU407OA4NYcMVaUakEQgSWLpMBBg2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-19 22:03 ` Jean Delvare
[not found] ` <20150119230327.0224d0ba-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-01-22 8:56 ` Michael Mercier
[not found] ` <1421917018.21840.0-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
2015-01-22 10:25 ` Jean Delvare
2015-01-22 10:49 ` Jean Delvare
[not found] ` <20150122114958.3178f5f6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-01-22 13:28 ` Michael Mercier
[not found] ` <1421933290.21840.1-YAXBhf1W29QAs8EywTwl9A@public.gmane.org>
2015-01-22 13:37 ` Jean Delvare
2015-01-26 11:46 ` Jean Delvare
[not found] ` <20150126124615.7fd1f64f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-04-09 20:32 ` Angelo Compagnucci
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.