Opened 12 years ago

Closed 10 years ago

#38666 closed defect (fixed)

Unable to successfully import lightblue after installation

Reported by: eroninjapan@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: Cc: gstein@…, kurthindenburg (Kurt Hindenburg)
Port: py-lightblue

Description (last modified by ryandesign (Ryan Carsten Schmidt))

I'm running OSX 10.8.3 and have included the error message as well as steps to reproduce below.

sudo port selfupdate

sudo port install py27-lightblue

$ python

Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import lightblue

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
    from _lightblue import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_lightblue.py", line 398, in <module>
    class _AsyncDeviceInquiry(Foundation.NSObject): 
TypeError: Error when calling the metaclass bases
    class _AsyncDeviceInquiry does not fully implement protocol IOBluetoothDeviceInquiryDelegate: no implementation for deviceInquiryDeviceNameUpdated:device:devicesRemaining:

Change History (12)

comment:1 Changed 12 years ago by cooljeanius (Eric Gallager)

What does which python return for you? By the version number it looks like you're using the system one. If that's the case, you might want to try doing sudo port select python python27 so that MacPorts's python27 is your default python.

comment:2 Changed 12 years ago by eroninjapan@…

I ran the commands and the output is below. I'm now using MacPort's Python27 but unfortunately I still encounter the same error when attempting the import.

$ which python
/usr/bin/python

$ sudo port select python python27
Selecting 'python27' for 'python' succeeded. 'python27' is now active.

$ which python
/opt/local/bin/python

$ python
Python 2.7.3 (default, Nov 17 2012, 19:54:34) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import lightblue
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
    from _lightblue import *
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_lightblue.py", line 398, in <module>
    class _AsyncDeviceInquiry(Foundation.NSObject): 
TypeError: Error when calling the metaclass bases
    class _AsyncDeviceInquiry does not fully implement protocol IOBluetoothDeviceInquiryDelegate: no implementation for deviceInquiryDeviceNameUpdated:device:devicesRemaining:
Last edited 12 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)

comment:4 Changed 12 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to michael.klein@…

In the future, please Cc the port maintainer(s).

comment:5 Changed 12 years ago by eroninjapan@…

Will do. Thanks for letting me know.

comment:6 Changed 12 years ago by sujitkrao@…

I'm having the same problem on 10.7.5, and looked a bit through the LightBlue source. The Python class _AsyncDeviceInquiry is a wrapper around the Objective-C class IOBluetoothDeviceInquiry and protocol IOBluetoothDeviceInquiryDelegate. It implements some, but not all, of the methods of IOBluetoothDeviceInquiryDelegate, and has a member variable instance IOBluetoothDeviceInquiry that it passes itself to on initialization. Before 10.7, IOBluetoothDeviceInquiryDelegate was an informal protocol, so all of the methods were optional. In 10.7 and later, IOBluetoothDeviceInquiryDelegate is a formal protocol with all of its methods explicitly declared optional, and it like PyObjC doesn't handle the optional methods correctly and throws an exception when not everything is implemented. I added the missing methods to _AsyncDeviceInquiry with empty implementations and it seemed to work:

def deviceInquiryDeviceNameUpdated_device_devicesRemaining_(self, sender, device, devicesRemaining):
    pass

def deviceInquiryUpdatingDeviceNamesStarted_devicesRemaining_(self, sender, devicesRemaining):
    pass

This is my first time messing with Objective-C and PyObjC, so the problem might actually be different, but I was able to import LightBlue after I added the methods. I haven't tested anything else.

comment:7 in reply to:  6 Changed 11 years ago by gstein@…

Replying to sujitkrao@…:

...

def deviceInquiryDeviceNameUpdated_device_devicesRemaining_(self, sender, device, devicesRemaining):
    pass

def deviceInquiryUpdatingDeviceNamesStarted_devicesRemaining_(self, sender, devicesRemaining):
    pass

I can confirm this patch is correct, and should be applied.

You'll note that "everybody" is applying a similar patch, when you look at the downstream network of postskolkovo/lightblue-0.4 at https://github.com/postskolkovo/lightblue-0.4/network

comment:8 Changed 11 years ago by gstein@…

Cc: gstein@… added

Cc Me!

comment:9 Changed 11 years ago by mf2k (Frank Schima)

If someone will spend the time to submit a proper patch, then maybe this will get committed.

comment:10 Changed 11 years ago by mf2k (Frank Schima)

Owner: changed from michael.klein@… to macports-tickets@…
Port: py-lightblue added; py27-lightblue removed

Michael is no longer maintaining this port. See r118707.

comment:11 Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Cc: khindenburg@… added

Cc Me!

comment:12 Changed 10 years ago by kurthindenburg (Kurt Hindenburg)

Resolution: fixed
Status: newclosed

fixed in r124057 - still doesn't work for me but that's a different error

Note: See TracTickets for help on using tickets.