Re: i2c-tools: add compatibility for python2/3 to py-smbus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux