bivab / smbus-cffi

Python bindings for Linux SMBus access through i2c-dev using cffi
GNU General Public License v2.0
61 stars 31 forks source link

does not compile on ArmOnArch #3

Closed simeonfelis closed 10 years ago

simeonfelis commented 10 years ago

I do::

export CPATH=/usr/lib/libffi-3.0.13/include/
pip2 install smbus-cffi

Downloading/unpacking smbus-cffi
  Downloading smbus-cffi-0.2.tar.gz
  Running setup.py egg_info for package smbus-cffi

    Installed /tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg
    Searching for pycparser
    Reading https://pypi.python.org/simple/pycparser/
    Best match: pycparser 2.10
    Downloading https://pypi.python.org/packages/source/p/pycparser/pycparser-2.10.tar.gz#md5=d87aed98c8a9f386aa56d365fe4d515f
    Processing pycparser-2.10.tar.gz
    Writing /tmp/easy_install-ZsGe8v/pycparser-2.10/setup.cfg
    Running pycparser-2.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZsGe8v/pycparser-2.10/egg-dist-tmp-NcALLa
    zip_safe flag not set; analyzing archive contents...

    Installed /tmp/pip_build_root/smbus-cffi/pycparser-2.10-py2.7.egg
    building '_cffi__x105b3718x176f443a' extension
    gcc -pthread -fno-strict-aliasing -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -DNDEBUG -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/python2.7 -c smbus/__pycache__/_cffi__x105b3718x176f443a.c -o /tmp/pip_build_root/smbus-cffi/smbus/__pycache__/smbus/__pycache__/_cffi__x105b3718x176f443a.o
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_BLOCK_DATA':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:498:20: error: 'I2C_SMBUS_BLOCK_DATA' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:498:20: note: each undeclared identifier is reported only once for each function it appears in
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_BLOCK_MAX':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:517:20: error: 'I2C_SMBUS_BLOCK_MAX' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_BLOCK_PROC_CALL':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:536:20: error: 'I2C_SMBUS_BLOCK_PROC_CALL' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_BYTE':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:555:20: error: 'I2C_SMBUS_BYTE' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_BYTE_DATA':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:574:20: error: 'I2C_SMBUS_BYTE_DATA' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_I2C_BLOCK_BROKEN':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:593:20: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_I2C_BLOCK_DATA':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:612:20: error: 'I2C_SMBUS_I2C_BLOCK_DATA' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_PROC_CALL':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:631:20: error: 'I2C_SMBUS_PROC_CALL' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_QUICK':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:650:20: error: 'I2C_SMBUS_QUICK' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_READ':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:669:20: error: 'I2C_SMBUS_READ' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_WORD_DATA':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:688:20: error: 'I2C_SMBUS_WORD_DATA' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_const_I2C_SMBUS_WRITE':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:707:20: error: 'I2C_SMBUS_WRITE' undeclared (first use in this function)
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_check_union_i2c_smbus_data':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:725:12: error: dereferencing pointer to incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:726:12: error: dereferencing pointer to incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:727:33: error: dereferencing pointer to incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c: In function '_cffi_layout_union_i2c_smbus_data':
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:732:58: error: field 'y' has incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:734:12: error: invalid application of 'sizeof' to incomplete type 'union i2c_smbus_data'
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:736:5: error: invalid use of undefined type 'union i2c_smbus_data'
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:737:39: error: dereferencing pointer to incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:738:5: error: invalid use of undefined type 'union i2c_smbus_data'
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:739:39: error: dereferencing pointer to incomplete type
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:740:5: error: invalid use of undefined type 'union i2c_smbus_data'
    smbus/__pycache__/_cffi__x105b3718x176f443a.c:741:39: error: dereferencing pointer to incomplete type
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip_build_root/smbus-cffi/setup.py", line 7, in <module>
        import smbus
      File "smbus/__init__.py", line 1, in <module>
        from .smbus import ffi
      File "smbus/smbus.py", line 93, in <module>
        """, ext_package='smbus')
      File "/tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg/cffi/api.py", line 339, in verify
        lib = self.verifier.load_library()
      File "/tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg/cffi/verifier.py", line 74, in load_library
        self._compile_module()
      File "/tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg/cffi/verifier.py", line 139, in _compile_module
        outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
      File "/tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg/cffi/ffiplatform.py", line 25, in compile
        outputfilename = _build(tmpdir, ext)
      File "/tmp/pip_build_root/smbus-cffi/cffi-0.8.1-py2.7-linux-armv6l.egg/cffi/ffiplatform.py", line 50, in _build
        raise VerificationError('%s: %s' % (e.__class__.__name__, e))
    cffi.ffiplatform.VerificationError: CompileError: command 'gcc' failed with exit status 1
    Complete output from command python setup.py egg_info:

[....]

Seems like a compatibility issue here...
simeonfelis commented 10 years ago

The same happens with

pip2 install git+https://github.com/bivab/smbus-cffi.git
simeonfelis commented 10 years ago

This happened with libffi version 3.0.13. I downgraded libffi version to 3.0.10 (the same as debian wheezy) and the same happend again.

bivab commented 10 years ago

Hi, thanks for the report. It seems you are missing some definitions in the i2c-dev header file that is included in the cffi module, causing it to fail installing the extension.

According to https://metacpan.org/pod/Device::SMBus you need to install the packages bellow to get required dependencies: pacman -S base-devel pacman -S i2c-tools

can you check this and report back?

Thanks

Radiognome1971 commented 10 years ago

I ran into just the same error on Archlinux on Raspberry Pi getting lots of the same compile-errors from gcc.

base-devel and i2c-tools installed... Using python2-pycparser 2.10-4

Hoping you can fix this. My C-knowledge is absolute minimal, and was just getting my toes wet on this i2c bus stuff.

Kind regards,

Martin

bivab commented 10 years ago

Hi @Radiognome1971, @simeonfelis smbus-cffi uses a header file from the i2c-tools project. Upon further investigation, it turns out that according to https://github.com/archlinuxarm/PKGBUILDs/issues/355 i2c-dev.h is not provided by the i2c-tools package on Arch Linux ARM and there seems to be no other package that provides this file.

While I'm evaluating a solution, here is a workaround that allows to install smbus-cffi Arch Linux ARM

Workaround

Radiognome1971 commented 10 years ago

Thanks a lot for a workaround. Helps me a lot, also to understand things (my reason to by a Pi and put Arch on it). Will try this next weekend.

Kind regards,

Martin


Martin Koch Duistereweg 8 3911 AK Rhenen

e-mail: mail@martinkoch.org

Op 31 mrt. 2014, om 21:25 heeft David Schneider notifications@github.com het volgende geschreven:

Hi @Radiognome1971, @simeonfelis smbus-cffi uses a header file from the i2c-tools project. Upon further investigation, it turns out that according to archlinuxarm/PKGBUILDs#355 i2c-dev.h is not provided by the i2c-tools package on Arch Linux ARM and there seems to be no other package that provides this file.

While I'm evaluating a solution, here is a workaround that allows to install smbus-cffi Arch Linux ARM

Workaround

Get i2c-dev.h and store it in a folder named linux/ (source: http://lm-sensors.org/svn/i2c-tools/tags/V3-1-1/include/linux/i2c-dev.h) Install smbus-cffi calling C_INCLUDE_PATH= pip install git+https://github.com/bivab/smbus-cffi.git Assuming i2c-dev.h is in /tmp/include/linux C_INCLUDE_PATH=/tmp/include/ pip install git+https://github.com/bivab/smbus-cffi.git — Reply to this email directly or view it on GitHub.

macsj200 commented 10 years ago

I'm in the same situation as Radiognome1971. I downloaded the header and included the directory the file was in and it still did not compile.

guardrex commented 10 years ago

Same outcome as macsj200 ... the workaround failed for me, too. I have base-devel and i2c-tools installed and followed the workaround instructions exactly. Any other options to get smbus running under Arch Linux?

bivab commented 10 years ago

Testing on arch linux, the issue should be fixed with rev: e25395729510453c830d05fb423542864cc0f59d Please reopen if there are still problems

AndreMiras commented 9 years ago

I had the issue in run time. The pip install smbus-cffi was OK, but I had the issue when trying to import smbus. I could solve the issue by installing libi2c-dev on Ubuntu 14.04 (Beagle Bone).

sudo apt install libi2c-dev