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

Fix _smbus_ffi relative import. #11

Closed lburg closed 9 years ago

lburg commented 9 years ago

Hi! I use smbus-cffi in one of my python project and since upgrading to 0.5.0, my tests broke because smbus was not able to import _smbus_cffi. I had the following error under python3.4:

ImportError: No module named 'util'

Here's a small PR that fixes this error, let me know if I missed anything.

lburg commented 9 years ago

Mh, the build broke because _smbus_cffi.so is not in the same directory as smbus.py, but when smbus-cffi is installed through pip, both files are in the same directory.

I guess that's a change to reproduce in the Travis configuration?

bivab commented 9 years ago

@lburg Thanks for the report, the issue should be fixed in HEAD. Let me know if any issues remain. I'll push an update to pypi soon

lburg commented 9 years ago

Thanks for your quick response! However, I tried installing smbus-cffi from git to get the latest version like so:

pip install git+https://github.com/bivab/smbus-cffi.git

And I still have an error:

ImportError: No module named 'smbus._smbus_cffi'

Here is what smbus looks like in my venv:

/home/lburg/.virtualenvs/project/lib/python3.4/site-packages/smbus/
├── __about__.py
├── __init__.py
├── __pycache__
│   ├── __about__.cpython-34.pyc
│   ├── __init__.cpython-34.pyc
│   ├── smbus.cpython-34.pyc
│   └── util.cpython-34.pyc
├── smbus
│   └── _smbus_cffi.cpython-34m.so
├── smbus.py
└── util.py

As you can see, a smbus/ folder is created which contains _smbus_cffi.cpython-34m.so. So now doing from ._smbus_cffi import ffi is incorrect... So I guess keeping the module name as _smbus_cffi is correct for a pypi release, but breaks Travis?

bivab commented 9 years ago

Thanks again for the report. Now everything should work for correctly in testing and installed with pip

lburg commented 9 years ago

Yep, it works. Thanks!